亚马逊api对接,店铺授权后获取code

import warnings

import requests

client_id = 'your_client_id'
client_secret = 'your_client_secret'
code = 'your_spapi_oauth_code'
redirect_uri = 'your_redirect_uri'
grant_type = 'authorization_code'

data = {
    'client_id': client_id,
    'client_secret': client_secret,
    'code': code,
    'redirect_uri': redirect_uri,
    'grant_type': grant_type
}

url = 'https://api.amazon.com/auth/o2/token'

warnings.filterwarnings('ignore', category=requests.packages.urllib3.exceptions.InsecureRequestWarning)

response = requests.post(url, data=data, verify=False)

if response.status_code == 200:
    token_response = response.json()
    print(response.text)
    access_token = token_response.get('access_token')
    print(f'Access Token: {access_token}')
else:
    print(f'Error: {response.status_code}, {response.text}')

  

 

done

 

posted @ 2025-06-03 15:57  liskov_design  阅读(37)  评论(0)    收藏  举报