3

I am using the SmartyStreets API to verify valid street addresses in New York City. I downloaded their example code file and I tried running it with a variety of different values. I tried my address, the address of Apples HQ, and even the stock address they had preloaded and nothing is working. This is the Example class and it is the shortest template of them all.

public class Example {
public static void main(String[] args) throws IOException, SmartyException {
    // This keypair will have been deleted by the time you are watching this video...
    String authId = "d418a4cc-69da-e48f-bc9d-ee7357b30d61";
    String authToken = "clDiwTlcW5YTFjEl5mp1";

    System.out.println("Step 0. Wire up the client with your keypair.");
    Client client = new ClientBuilder(authId, authToken).buildUsStreetApiClient();

    System.out.println("Step 1. Make a lookup. (BTW, you can also send entire batches of lookups...)");
    Lookup lookup = new Lookup();
    lookup.setStreet("1 Rosedale");
    lookup.setLastline("Baltimore MD");
    lookup.setMaxCandidates(10);

    System.out.println("Step 2. Send the lookup.");
    client.send(lookup);

    System.out.println("Step 3. Show the resulting candidate addresses:");
    int index = 0;
    for (Candidate candidate : lookup.getResult()) {
        System.out.printf("- %d: %s, %s\n", index, candidate.getDeliveryLine1(), candidate.getLastLine());
        index++;
    }
}

The message I am supposed to get after running this main method is:

Step 0. Wire up the client with your keypair.
Step 1. Make a lookup. (BTW, you can also send entire batches of lookups...)
Step 2. Send the lookup.
Step 3. Show the resulting candidate addresses:
- 0: 1 N Rosedale St, Baltimore MD 21229-3737
- 1: 1 S Rosedale St, Baltimore MD 21229-3739

But instead I am getting this and an error code:

Step 0. Wire up the client with your keypair.
Step 1. Make a lookup. (BTW, you can also send entire batches of lookups...)
Step 2. Send the lookup.
Exception in thread "main" com.smartystreets.api.exceptions.BadCredentialsException: Unauthorized: The credentials were provided incorrectly or did not match any existing, active credentials.
    at com.smartystreets.api.StatusCodeSender.send(StatusCodeSender.java:21)
    at com.smartystreets.api.SigningSender.send(SigningSender.java:18)
    at com.smartystreets.api.URLPrefixSender.send(URLPrefixSender.java:19)
    at com.smartystreets.api.RetrySender.trySend(RetrySender.java:34)
    at com.smartystreets.api.RetrySender.send(RetrySender.java:23)
    at com.smartystreets.api.us_street.Client.send(Client.java:48)
    at com.smartystreets.api.us_street.Client.send(Client.java:27)
    at examples.Example.main(Example.java:25)

Process finished with exit code 1
Wizard
  • 462
  • 1
  • 6
  • 14
  • 3
    Are you using the credentials shown in your example? Those aren't valid. They were put there merely for demonstration. You are expected to use your own credentials. – Jeffrey Jul 31 '20 at 05:00
  • 1
    @Jeffrey where do I get the credentials from, am I supposed to use my login for the site? if so how do I translate that into the String. – Wizard Jul 31 '20 at 05:05
  • 1
    You many follow the [API documentation from SmartyStreets](https://smartystreets.com/docs/cloud/authentication) – Arindam Roy Jul 31 '20 at 05:19

1 Answers1

4

SOLUTION: I received the following solution for my problem privately with whom I assume is a developer for the program.

Go to the following link https://account.smartystreets.com/#keys

Login and scroll to the bottom of the page where it says auto-generated. You must take the auth-id and auth-token values from here and use them to replace the dummy values in the Example class.

At this point you are able to test out whatever addresses you want in USA. For rulings on what combinations and parts of addresses are required check this link: https://smartystreets.com/docs/cloud/us-street-api#root

Wizard
  • 462
  • 1
  • 6
  • 14