Skip to content

Commit ee3a63d

Browse files
authored
Ryan/basic auth (#77)
* Add basic auth * add a test_dev so we can run the tests locally from a Mac.
1 parent bf2a549 commit ee3a63d

18 files changed

Lines changed: 182 additions & 82 deletions

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ clean:
66
rm -rf dist/ MANIFEST
77
git checkout "$(VERSION_FILE)"
88

9+
test_dev: clean
10+
python3 -m unittest discover -p *_test.py
11+
912
test: clean dependencies
1013
python3 -m unittest discover -p *_test.py
1114

examples/international_autocomplete_example.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22

3-
from smartystreets_python_sdk import SharedCredentials, ClientBuilder, StaticCredentials
3+
from smartystreets_python_sdk import SharedCredentials, ClientBuilder, BasicAuthCredentials
44
from smartystreets_python_sdk.international_autocomplete import Lookup as InternationalAutocompleteLookup
55

66

@@ -10,16 +10,16 @@ def run():
1010

1111
# We recommend storing your secret keys in environment variables instead---it's safer!
1212
# for client-side requests (browser/mobile), use this code:
13-
key = os.environ['SMARTY_AUTH_WEB']
14-
hostname = os.environ['SMARTY_WEBSITE_DOMAIN']
15-
16-
credentials = SharedCredentials(key, hostname)
13+
# key = os.environ['SMARTY_AUTH_WEB']
14+
# hostname = os.environ['SMARTY_WEBSITE_DOMAIN']
15+
#
16+
# credentials = SharedCredentials(key, hostname)
1717

1818
# for server-to-server requests, use this code:
19-
# auth_id = os.environ['SMARTY_AUTH_ID']
20-
# auth_token = os.environ['SMARTY_AUTH_TOKEN']
21-
#
22-
# credentials = StaticCredentials(auth_id, auth_token)
19+
auth_id = os.environ['SMARTY_AUTH_ID']
20+
auth_token = os.environ['SMARTY_AUTH_TOKEN']
21+
22+
credentials = BasicAuthCredentials(auth_id, auth_token)
2323

2424
client = ClientBuilder(credentials).build_international_autocomplete_api_client()
2525

examples/international_example.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22

3-
from smartystreets_python_sdk import StaticCredentials, ClientBuilder, SharedCredentials
3+
from smartystreets_python_sdk import BasicAuthCredentials, ClientBuilder, SharedCredentials
44
from smartystreets_python_sdk.international_street import Lookup as InternationalLookup
55

66

@@ -10,16 +10,16 @@ def run():
1010

1111
# We recommend storing your secret keys in environment variables instead---it's safer!
1212
# for client-side requests (browser/mobile), use this code:
13-
key = os.environ['SMARTY_AUTH_WEB']
14-
hostname = os.environ['SMARTY_WEBSITE_DOMAIN']
15-
16-
credentials = SharedCredentials(key, hostname)
13+
# key = os.environ['SMARTY_AUTH_WEB']
14+
# hostname = os.environ['SMARTY_WEBSITE_DOMAIN']
15+
#
16+
# credentials = SharedCredentials(key, hostname)
1717

1818
# for server-to-server requests, use this code:
19-
# auth_id = os.environ['SMARTY_AUTH_ID']
20-
# auth_token = os.environ['SMARTY_AUTH_TOKEN']
21-
#
22-
# credentials = StaticCredentials(auth_id, auth_token)
19+
auth_id = os.environ['SMARTY_AUTH_ID']
20+
auth_token = os.environ['SMARTY_AUTH_TOKEN']
21+
22+
credentials = BasicAuthCredentials(auth_id, auth_token)
2323

2424
client = ClientBuilder(credentials).build_international_street_api_client()
2525

examples/international_postal_code_example.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22

3-
from smartystreets_python_sdk import StaticCredentials, ClientBuilder
3+
from smartystreets_python_sdk import BasicAuthCredentials, ClientBuilder, SharedCredentials
44
from smartystreets_python_sdk.international_postal_code import Lookup
55

66

@@ -12,13 +12,14 @@ def run():
1212
# for client-side requests (browser/mobile), use this code:
1313
# key = os.environ['SMARTY_AUTH_WEB']
1414
# hostname = os.environ['SMARTY_WEBSITE_DOMAIN']
15+
#
1516
# credentials = SharedCredentials(key, hostname)
1617

1718
# for server-to-server requests, use this code:
1819
auth_id = os.environ['SMARTY_AUTH_ID']
1920
auth_token = os.environ['SMARTY_AUTH_TOKEN']
20-
21-
credentials = StaticCredentials(auth_id, auth_token)
21+
22+
credentials = BasicAuthCredentials(auth_id, auth_token)
2223

2324
client = ClientBuilder(credentials).build_international_postal_code_api_client()
2425

examples/us_autocomplete_pro_example.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22

3-
from smartystreets_python_sdk import SharedCredentials, StaticCredentials, ClientBuilder
3+
from smartystreets_python_sdk import SharedCredentials, BasicAuthCredentials, ClientBuilder
44
from smartystreets_python_sdk.us_autocomplete_pro import Lookup as AutocompleteProLookup, geolocation_type
55

66

@@ -19,13 +19,7 @@ def run():
1919
auth_id = os.environ['SMARTY_AUTH_ID']
2020
auth_token = os.environ['SMARTY_AUTH_TOKEN']
2121

22-
credentials = StaticCredentials(auth_id, auth_token)
23-
24-
# for server-to-server requests, use this code:
25-
# auth_id = os.environ['SMARTY_AUTH_ID']
26-
# auth_token = os.environ['SMARTY_AUTH_TOKEN']
27-
#
28-
# credentials = StaticCredentials(auth_id, auth_token)
22+
credentials = BasicAuthCredentials(auth_id, auth_token)
2923

3024
client = ClientBuilder(credentials).build_us_autocomplete_pro_api_client()
3125

examples/us_enrichment_example.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11
import os
22

3-
from smartystreets_python_sdk import SharedCredentials, StaticCredentials, exceptions, ClientBuilder
3+
from smartystreets_python_sdk import SharedCredentials, BasicAuthCredentials, exceptions, ClientBuilder
44
from smartystreets_python_sdk.us_enrichment.lookup import Lookup as EnrichmentLookup
55

66

7-
# from smartystreets_python_sdk.us_enrichment import
8-
97
def run():
108
# key = "Your SmartyStreets Key here"
119
# hostname = "Your Hostname here"
1210

1311
# We recommend storing your secret keys in environment variables instead---it's safer!
1412
# for client-side requests (browser/mobile), use this code:
15-
#key = os.environ['SMARTY_AUTH_WEB']
16-
#hostname = os.environ['SMARTY_WEBSITE_DOMAIN']
17-
18-
#credentials = SharedCredentials(key, hostname)
13+
# key = os.environ['SMARTY_AUTH_WEB']
14+
# hostname = os.environ['SMARTY_WEBSITE_DOMAIN']
15+
#
16+
# credentials = SharedCredentials(key, hostname)
1917

2018
# for server-to-server requests, use this code:
2119
auth_id = os.environ['SMARTY_AUTH_ID']
2220
auth_token = os.environ['SMARTY_AUTH_TOKEN']
23-
#
24-
credentials = StaticCredentials(auth_id, auth_token)
21+
22+
credentials = BasicAuthCredentials(auth_id, auth_token)
2523

2624
client = ClientBuilder(credentials).build_us_enrichment_api_client()
2725

examples/us_extract_example.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22

3-
from smartystreets_python_sdk import SharedCredentials, StaticCredentials, ClientBuilder
3+
from smartystreets_python_sdk import SharedCredentials, BasicAuthCredentials, ClientBuilder
44
from smartystreets_python_sdk.us_extract import Lookup as ExtractLookup
55
from smartystreets_python_sdk.us_street.match_type import MatchType
66

@@ -11,16 +11,16 @@ def run():
1111

1212
# We recommend storing your secret keys in environment variables instead---it's safer!
1313
# for client-side requests (browser/mobile), use this code:
14-
key = os.environ['SMARTY_AUTH_WEB']
15-
hostname = os.environ['SMARTY_WEBSITE_DOMAIN']
16-
17-
credentials = SharedCredentials(key, hostname)
14+
# key = os.environ['SMARTY_AUTH_WEB']
15+
# hostname = os.environ['SMARTY_WEBSITE_DOMAIN']
16+
#
17+
# credentials = SharedCredentials(key, hostname)
1818

1919
# for server-to-server requests, use this code:
20-
# auth_id = os.environ['SMARTY_AUTH_ID']
21-
# auth_token = os.environ['SMARTY_AUTH_TOKEN']
22-
#
23-
# credentials = StaticCredentials(auth_id, auth_token)
20+
auth_id = os.environ['SMARTY_AUTH_ID']
21+
auth_token = os.environ['SMARTY_AUTH_TOKEN']
22+
23+
credentials = BasicAuthCredentials(auth_id, auth_token)
2424

2525
client = ClientBuilder(credentials).build_us_extract_api_client()
2626

examples/us_reverse_geo_example.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22

3-
from smartystreets_python_sdk import SharedCredentials, StaticCredentials, ClientBuilder
3+
from smartystreets_python_sdk import SharedCredentials, BasicAuthCredentials, ClientBuilder
44
from smartystreets_python_sdk.us_reverse_geo import Lookup
55

66

@@ -10,16 +10,16 @@ def run():
1010

1111
# We recommend storing your secret keys in environment variables instead---it's safer!
1212
# for client-side requests (browser/mobile), use this code:
13-
key = os.environ['SMARTY_AUTH_WEB']
14-
hostname = os.environ['SMARTY_WEBSITE_DOMAIN']
15-
16-
credentials = SharedCredentials(key, hostname)
13+
# key = os.environ['SMARTY_AUTH_WEB']
14+
# hostname = os.environ['SMARTY_WEBSITE_DOMAIN']
15+
#
16+
# credentials = SharedCredentials(key, hostname)
1717

1818
# for server-to-server requests, use this code:
19-
# auth_id = os.environ['SMARTY_AUTH_ID']
20-
# auth_token = os.environ['SMARTY_AUTH_TOKEN']
21-
#
22-
# credentials = StaticCredentials(auth_id, auth_token)
19+
auth_id = os.environ['SMARTY_AUTH_ID']
20+
auth_token = os.environ['SMARTY_AUTH_TOKEN']
21+
22+
credentials = BasicAuthCredentials(auth_id, auth_token)
2323

2424
client = ClientBuilder(credentials).build_us_reverse_geo_api_client()
2525

examples/us_street_component_analysis_example.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import os
33
import json
44

5-
from smartystreets_python_sdk import SharedCredentials, StaticCredentials, exceptions, ClientBuilder
5+
from smartystreets_python_sdk import SharedCredentials, BasicAuthCredentials, exceptions, ClientBuilder
66
from smartystreets_python_sdk.us_street import Lookup as StreetLookup
77
from smartystreets_python_sdk.us_street.match_type import MatchType
88

@@ -11,12 +11,14 @@ def run():
1111
# For client-side requests (browser/mobile), use this code:
1212
# key = os.environ['SMARTY_AUTH_WEB']
1313
# hostname = os.environ['SMARTY_WEBSITE_DOMAIN']
14+
#
1415
# credentials = SharedCredentials(key, hostname)
1516

1617
# For server-to-server requests, use this code:
1718
auth_id = os.environ['SMARTY_AUTH_ID']
1819
auth_token = os.environ['SMARTY_AUTH_TOKEN']
19-
credentials = StaticCredentials(auth_id, auth_token)
20+
21+
credentials = BasicAuthCredentials(auth_id, auth_token)
2022

2123
client = ( ClientBuilder(credentials)
2224
.with_feature_component_analysis() # To add component analysis feature you need to specify when you create the client.

examples/us_street_multiple_addresses_example.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22

3-
from smartystreets_python_sdk import SharedCredentials, StaticCredentials, exceptions, Batch, ClientBuilder
3+
from smartystreets_python_sdk import SharedCredentials, BasicAuthCredentials, exceptions, Batch, ClientBuilder
44
from smartystreets_python_sdk.us_street import Lookup as StreetLookup
55
from smartystreets_python_sdk.us_street.match_type import MatchType
66

@@ -13,14 +13,14 @@ def run():
1313
# for client-side requests (browser/mobile), use this code:
1414
# key = os.environ['SMARTY_AUTH_WEB']
1515
# hostname = os.environ['SMARTY_WEBSITE_DOMAIN']
16-
16+
#
1717
# credentials = SharedCredentials(key, hostname)
1818

1919
# for server-to-server requests, use this code:
2020
auth_id = os.environ['SMARTY_AUTH_ID']
2121
auth_token = os.environ['SMARTY_AUTH_TOKEN']
22-
23-
credentials = StaticCredentials(auth_id, auth_token)
22+
23+
credentials = BasicAuthCredentials(auth_id, auth_token)
2424

2525
client = ClientBuilder(credentials).build_us_street_api_client()
2626

0 commit comments

Comments
 (0)