File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,5 +16,6 @@ All endpoint's clients have the following signature and default values:
1616 marketplace = Marketplaces.US , * ,
1717 refresh_token = None ,
1818 account = ' default' ,
19- credentials = None
19+ credentials = None ,
20+ restricted_data_token = None
2021 )
Original file line number Diff line number Diff line change 66
77
88.. autoclass :: sp_api.api.Orders
9+
10+
11+
12+ Restricted Data Token
13+ =====================
14+
15+ To use a restricted data token to access PII data, you can pass the token obtained from the Token endpoint to the client:
16+
17+ .. code-block :: python
18+
19+ Orders(restricted_data_token = ' ......' ).get_orders(... )
20+
21+
22+
23+
24+
Original file line number Diff line number Diff line change 22
33setup (
44 name = 'python-amazon-sp-api' ,
5- version = '0.6.8 ' ,
5+ version = '0.7.0 ' ,
66 install_requires = [
77 "requests" ,
88 "six>=1.15,<2" ,
Original file line number Diff line number Diff line change @@ -29,7 +29,8 @@ def __init__(
2929 * ,
3030 refresh_token = None ,
3131 account = 'default' ,
32- credentials = None
32+ credentials = None ,
33+ restricted_data_token = None
3334 ):
3435 super ().__init__ (account , credentials )
3536 self .boto3_client = boto3 .client (
@@ -40,6 +41,7 @@ def __init__(
4041 self .endpoint = marketplace .endpoint
4142 self .marketplace_id = marketplace .marketplace_id
4243 self .region = marketplace .region
44+ self .restricted_data_token = restricted_data_token
4345 self ._auth = AccessTokenClient (refresh_token = refresh_token , account = account , credentials = credentials )
4446
4547 def _get_cache_key (self , token_flavor = '' ):
@@ -61,7 +63,7 @@ def headers(self):
6163 return {
6264 'host' : self .endpoint [8 :],
6365 'user-agent' : self .user_agent ,
64- 'x-amz-access-token' : self .auth .access_token ,
66+ 'x-amz-access-token' : self .restricted_data_token or self . auth .access_token ,
6567 'x-amz-date' : datetime .utcnow ().strftime ('%Y%m%dT%H%M%SZ' ),
6668 'content-type' : 'application/json'
6769 }
Original file line number Diff line number Diff line change 1+ from datetime import timedelta , datetime
2+
3+ import pytest
4+
5+ from sp_api .api import Tokens , Orders
6+ from sp_api .base import SellingApiBadRequestException , Marketplaces
7+
8+ #
9+ # def test_get_token_for_bulk_orders():
10+ # with pytest.raises(SellingApiBadRequestException) as info:
11+ # res = Tokens().create_restricted_data_token(restrictedResources=[
12+ # {
13+ # "method": "GET",
14+ # "path": "/orders/v0/orders",
15+ # "dataElements": ["buyerInfo", "shippingAddress"]
16+ # }
17+ # ])
18+ # print(res)
19+ #
20+ #
21+ # def test_get_order_with_token():
22+ # res = Orders(restricted_data_token='foo').get_orders(CreatedAfter=(datetime.now() - timedelta(days=10)).isoformat())
23+ # print(res)
You can’t perform that action at this time.
0 commit comments