Skip to content

Commit d916e82

Browse files
authored
Merge pull request #125 from smarty/ryan/basic_auth
Ryan/basic auth
2 parents 4e34af7 + 50e3b54 commit d916e82

14 files changed

+212
-77
lines changed

examples/international_address_autocomplete.mjs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ import SmartySDK from "smartystreets-javascript-sdk";
33
const SmartyCore = SmartySDK.core;
44
const Lookup = SmartySDK.internationalAddressAutocomplete.Lookup;
55

6-
// for Server-to-server requests, use this code:
7-
// let authId = process.env.SMARTY_AUTH_ID;
8-
// let authToken = process.env.SMARTY_AUTH_TOKEN;
9-
// const credentials = new SmartyCore.StaticCredentials(authId, authToken);
10-
116
// for client-side requests (browser/mobile), use this code:
12-
const key = process.env.SMARTY_EMBEDDED_KEY;
13-
const credentials = new SmartyCore.SharedCredentials(key);
7+
// const key = process.env.SMARTY_EMBEDDED_KEY;
8+
// const credentials = new SmartyCore.SharedCredentials(key);
9+
10+
// for Server-to-server requests, use this code:
11+
const authId = process.env.SMARTY_AUTH_ID;
12+
const authToken = process.env.SMARTY_AUTH_TOKEN;
13+
const credentials = new SmartyCore.BasicAuthCredentials(authId, authToken);
1414

1515
// The appropriate license values to be used for your subscriptions
1616
// can be found on the Subscription page of the account dashboard.
1717
// https://www.smarty.com/docs/cloud/licensing
18-
const clientBuilder = new SmartyCore.ClientBuilder(credentials).withLicenses(["international-autocomplete-v2-cloud"])
19-
// .withBaseUrl("YOUR URL") // withBaseUrl() should be used if you are self-hosting the Smarty API
18+
const clientBuilder = new SmartyCore.ClientBuilder(credentials);
19+
// .withBaseUrl("YOUR URL") // withBaseUrl() should be used if you are self-hosting the Smarty API
2020

2121
const client = clientBuilder.buildInternationalAddressAutocompleteClient();
2222

examples/international_postal_code.mjs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import SmartySDK from "smartystreets-javascript-sdk";
33
const SmartyCore = SmartySDK.core;
44
const Lookup = SmartySDK.internationalPostalCode.Lookup;
55

6-
// for Server-to-server requests, use this code:
7-
// let authId = process.env.SMARTY_AUTH_ID;
8-
// let authToken = process.env.SMARTY_AUTH_TOKEN;
9-
// const credentials = new SmartyCore.StaticCredentials(authId, authToken);
10-
116
// for client-side requests (browser/mobile), use this code:
12-
let key = process.env.SMARTY_EMBEDDED_KEY;
13-
const credentials = new SmartyCore.SharedCredentials(key);
7+
// let key = process.env.SMARTY_EMBEDDED_KEY;
8+
// const credentials = new SmartyCore.SharedCredentials(key);
9+
10+
// for Server-to-server requests, use this code:
11+
let authId = process.env.SMARTY_AUTH_ID;
12+
let authToken = process.env.SMARTY_AUTH_TOKEN;
13+
const credentials = new SmartyCore.BasicAuthCredentials(authId, authToken);
1414

1515
// The appropriate license values to be used for your subscriptions
1616
// can be found on the Subscription page of the account dashboard.

examples/international_street.mjs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ import SmartySDK from "smartystreets-javascript-sdk";
33
const SmartyCore = SmartySDK.core;
44
const Lookup = SmartySDK.internationalStreet.Lookup;
55

6-
// for Server-to-server requests, use this code:
7-
// let authId = process.env.SMARTY_AUTH_ID;
8-
// let authToken = process.env.SMARTY_AUTH_TOKEN;
9-
// const credentials = new SmartyCore.StaticCredentials(authId, authToken);
10-
116
// for client-side requests (browser/mobile), use this code:
12-
let key = process.env.SMARTY_EMBEDDED_KEY;
13-
const credentials = new SmartyCore.SharedCredentials(key);
7+
// let key = process.env.SMARTY_EMBEDDED_KEY;
8+
// const credentials = new SmartyCore.SharedCredentials(key);
9+
10+
// for Server-to-server requests, use this code:
11+
let authId = process.env.SMARTY_AUTH_ID;
12+
let authToken = process.env.SMARTY_AUTH_TOKEN;
13+
const credentials = new SmartyCore.BasicAuthCredentials(authId, authToken);
1414

1515
// The appropriate license values to be used for your subscriptions
1616
// can be found on the Subscription page of the account dashboard.
1717
// https://www.smarty.com/docs/cloud/licensing
18-
let clientBuilder = new SmartyCore.ClientBuilder(credentials).withLicenses(["international-global-plus-cloud"]);
19-
// .withBaseUrl("YOUR URL") // withBaseUrl() should be used if you are self-hosting the Smarty API
18+
let clientBuilder = new SmartyCore.ClientBuilder(credentials);
19+
// .withBaseUrl("YOUR URL") // withBaseUrl() should be used if you are self-hosting the Smarty API
2020

2121
let client = clientBuilder.buildInternationalStreetClient();
2222

examples/us_autocomplete_pro.mjs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ import SmartySDK from "smartystreets-javascript-sdk";
33
const SmartyCore = SmartySDK.core;
44
const Lookup = SmartySDK.usAutocompletePro.Lookup;
55

6-
// for Server-to-server requests, use this code:
7-
// let authId = process.env.SMARTY_AUTH_ID;
8-
// let authToken = process.env.SMARTY_AUTH_TOKEN;
9-
// const credentials = new SmartyCore.StaticCredentials(authId, authToken);
10-
116
// for client-side requests (browser/mobile), use this code:
12-
let key = process.env.SMARTY_EMBEDDED_KEY;
13-
const credentials = new SmartyCore.SharedCredentials(key);
7+
// let key = process.env.SMARTY_EMBEDDED_KEY;
8+
// const credentials = new SmartyCore.SharedCredentials(key);
9+
10+
// for Server-to-server requests, use this code:
11+
let authId = process.env.SMARTY_AUTH_ID;
12+
let authToken = process.env.SMARTY_AUTH_TOKEN;
13+
const credentials = new SmartyCore.BasicAuthCredentials(authId, authToken);
1414

1515
// The appropriate license values to be used for your subscriptions
1616
// can be found on the Subscription page of the account dashboard.
1717
// https://www.smarty.com/docs/cloud/licensing
18-
let clientBuilder = new SmartyCore.ClientBuilder(credentials).withLicenses(["us-autocomplete-pro-cloud"]);
19-
// .withBaseUrl("YOUR URL") // withBaseUrl() should be used if you are self-hosting the Smarty API
18+
let clientBuilder = new SmartyCore.ClientBuilder(credentials);
19+
// .withBaseUrl("YOUR URL") // withBaseUrl() should be used if you are self-hosting the Smarty API
2020

2121
let client = clientBuilder.buildUsAutocompleteProClient();
2222

examples/us_enrichment.mjs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ import SmartySDK from "smartystreets-javascript-sdk";
33
const SmartyCore = SmartySDK.core;
44
const Lookup = SmartySDK.usEnrichment.Lookup;
55

6-
// for Server-to-server requests, use this code:
7-
// let authId = process.env.SMARTY_AUTH_ID;
8-
// let authToken = process.env.SMARTY_AUTH_TOKEN;
9-
// const credentials = new SmartyCore.StaticCredentials(authId, authToken);
10-
116
// for client-side requests (browser/mobile), use this code:
12-
let key = process.env.SMARTY_EMBEDDED_KEY;
13-
const credentials = new SmartyCore.SharedCredentials(key);
7+
// let key = process.env.SMARTY_EMBEDDED_KEY;
8+
// const credentials = new SmartyCore.SharedCredentials(key);
9+
10+
// for Server-to-server requests, use this code:
11+
let authId = process.env.SMARTY_AUTH_ID;
12+
let authToken = process.env.SMARTY_AUTH_TOKEN;
13+
const credentials = new SmartyCore.BasicAuthCredentials(authId, authToken);
1414

1515
// The appropriate license values to be used for your subscriptions
1616
// can be found on the Subscription page of the account dashboard.
1717
// https://www.smarty.com/docs/cloud/licensing
18-
let clientBuilder = new SmartyCore.ClientBuilder(credentials).withLicenses(["us-property-data-principal-cloud"]);
19-
// .withBaseUrl("YOUR URL") // withBaseUrl() should be used if you are self-hosting the Smarty API
18+
let clientBuilder = new SmartyCore.ClientBuilder(credentials);
19+
// .withBaseUrl("YOUR URL") // withBaseUrl() should be used if you are self-hosting the Smarty API
2020

2121
let client = clientBuilder.buildUsEnrichmentClient();
2222

examples/us_extract.mjs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import SmartySDK from "smartystreets-javascript-sdk";
33
const SmartyCore = SmartySDK.core;
44
const Lookup = SmartySDK.usExtract.Lookup;
55

6-
// for Server-to-server requests, use this code:
7-
// let authId = process.env.SMARTY_AUTH_ID;
8-
// let authToken = process.env.SMARTY_AUTH_TOKEN;
9-
// const credentials = new SmartyCore.StaticCredentials(authId, authToken);
10-
116
// for client-side requests (browser/mobile), use this code:
12-
let key = process.env.SMARTY_EMBEDDED_KEY;
13-
const credentials = new SmartyCore.SharedCredentials(key);
7+
// let key = process.env.SMARTY_EMBEDDED_KEY;
8+
// const credentials = new SmartyCore.SharedCredentials(key);
9+
10+
// for Server-to-server requests, use this code:
11+
let authId = process.env.SMARTY_AUTH_ID;
12+
let authToken = process.env.SMARTY_AUTH_TOKEN;
13+
const credentials = new SmartyCore.BasicAuthCredentials(authId, authToken);
1414

1515
let clientBuilder = new SmartyCore.ClientBuilder(credentials);
1616
// .withBaseUrl("YOUR URL") // withBaseUrl() should be used if you are self-hosting the Smarty API

examples/us_reverse_geo.mjs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ import SmartySDK from "smartystreets-javascript-sdk";
33
const SmartyCore = SmartySDK.core;
44
const Lookup = SmartySDK.usReverseGeo.Lookup;
55

6-
// for Server-to-server requests, use this code:
7-
// let authId = process.env.SMARTY_AUTH_ID;
8-
// let authToken = process.env.SMARTY_AUTH_TOKEN;
9-
// const credentials = new SmartyCore.StaticCredentials(authId, authToken);
10-
116
// for client-side requests (browser/mobile), use this code:
12-
let key = process.env.SMARTY_EMBEDDED_KEY;
13-
const credentials = new SmartyCore.SharedCredentials(key);
7+
// let key = process.env.SMARTY_EMBEDDED_KEY;
8+
// const credentials = new SmartyCore.SharedCredentials(key);
9+
10+
// for Server-to-server requests, use this code:
11+
let authId = process.env.SMARTY_AUTH_ID;
12+
let authToken = process.env.SMARTY_AUTH_TOKEN;
13+
const credentials = new SmartyCore.BasicAuthCredentials(authId, authToken);
1414

1515
// The appropriate license values to be used for your subscriptions
1616
// can be found on the Subscription page of the account dashboard.
1717
// https://www.smarty.com/docs/cloud/licensing
18-
let clientBuilder = new SmartyCore.ClientBuilder(credentials).withLicenses(["us-reverse-geocoding-cloud"]);
19-
// .withBaseUrl("YOUR URL") // withBaseUrl() should be used if you are self-hosting the Smarty API
18+
let clientBuilder = new SmartyCore.ClientBuilder(credentials);
19+
// .withBaseUrl("YOUR URL") // withBaseUrl() should be used if you are self-hosting the Smarty API
2020
let client = clientBuilder.buildUsReverseGeoClient();
2121

2222
let lookup1 = new Lookup(40.27644, -111.65747);

examples/us_street.mjs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,19 @@ import SmartySDK from "smartystreets-javascript-sdk";
33
const SmartyCore = SmartySDK.core;
44
const Lookup = SmartySDK.usStreet.Lookup;
55

6-
// for Server-to-server requests, use this code:
7-
// let authId = process.env.SMARTY_AUTH_ID;
8-
// let authToken = process.env.SMARTY_AUTH_TOKEN;
9-
// const credentials = new SmartyCore.StaticCredentials(authId, authToken);
10-
116
// for client-side requests (browser/mobile), use this code:
12-
let key = process.env.SMARTY_EMBEDDED_KEY;
13-
const credentials = new SmartyCore.SharedCredentials(key);
7+
// let key = process.env.SMARTY_EMBEDDED_KEY;
8+
// const credentials = new SmartyCore.SharedCredentials(key);
9+
10+
// for Server-to-server requests, use this code:
11+
let authId = process.env.SMARTY_AUTH_ID;
12+
let authToken = process.env.SMARTY_AUTH_TOKEN;
13+
const credentials = new SmartyCore.BasicAuthCredentials(authId, authToken);
1414

1515
// The appropriate license values to be used for your subscriptions
1616
// can be found on the Subscription page of the account dashboard.
1717
// https://www.smarty.com/docs/cloud/licensing
18-
let clientBuilder = new SmartyCore.ClientBuilder(credentials).withLicenses([
19-
"us-rooftop-geocoding-cloud",
20-
]);
18+
let clientBuilder = new SmartyCore.ClientBuilder(credentials);
2119
// .withBaseUrl("YOUR URL") // withBaseUrl() should be used if you are self-hosting the Smarty API
2220

2321
let client = clientBuilder.buildUsStreetApiClient();

examples/us_zipcode.mjs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import SmartySDK from "smartystreets-javascript-sdk";
33
const SmartyCore = SmartySDK.core;
44
const Lookup = SmartySDK.usZipcode.Lookup;
55

6-
// for Server-to-server requests, use this code:
7-
// let authId = process.env.SMARTY_AUTH_ID;
8-
// let authToken = process.env.SMARTY_AUTH_TOKEN;
9-
// const credentials = new SmartyCore.StaticCredentials(authId, authToken);
10-
116
// for client-side requests (browser/mobile), use this code:
12-
let key = process.env.SMARTY_EMBEDDED_KEY;
13-
const credentials = new SmartyCore.SharedCredentials(key);
7+
// let key = process.env.SMARTY_EMBEDDED_KEY;
8+
// const credentials = new SmartyCore.SharedCredentials(key);
9+
10+
// for Server-to-server requests, use this code:
11+
let authId = process.env.SMARTY_AUTH_ID;
12+
let authToken = process.env.SMARTY_AUTH_TOKEN;
13+
const credentials = new SmartyCore.BasicAuthCredentials(authId, authToken);
1414

1515
let clientBuilder = new SmartyCore.ClientBuilder(credentials);
1616
// .withBaseUrl("YOUR URL") // withBaseUrl() should be used if you are self-hosting the Smarty API

index.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import ClientBuilder from "./src/ClientBuilder.js";
77
import buildClient from "./src/util/buildClients.js";
88
import SharedCredentials from "./src/SharedCredentials.js";
99
import StaticCredentials from "./src/StaticCredentials.js";
10+
import BasicAuthCredentials from "./src/BasicAuthCredentials.js";
1011
import Errors from "./src/Errors.js";
1112

1213
import LookupUSStreet from "./src/us_street/Lookup.js";
@@ -41,6 +42,7 @@ export const core = {
4142
buildClient,
4243
SharedCredentials,
4344
StaticCredentials,
45+
BasicAuthCredentials,
4446
Errors,
4547
};
4648

0 commit comments

Comments
 (0)