要从单个eBay开发人员帐户访问多个商店,您需要使用eBay的OAuth 2.0认证机制。以下是详细步骤和相关概念:
以下是一个使用requests_oauthlib
库获取访问令牌的示例:
from requests_oauthlib import OAuth2Session
# 配置您的Client ID和Client Secret
client_id = 'YOUR_CLIENT_ID'
client_secret = 'YOUR_CLIENT_SECRET'
authorization_base_url = 'https://auth.ebay.com/oauth2/authorize'
token_url = 'https://api.ebay.com/identity/v1/oauth2/token'
# 创建OAuth2会话
oauth = OAuth2Session(client_id)
# 获取授权URL
authorization_url, state = oauth.authorization_url(authorization_base_url)
print(f'Please go to {authorization_url} and authorize access.')
# 用户授权后,获取授权码
redirect_response = input('Paste the full redirect URL here: ')
# 使用授权码获取访问令牌
token = oauth.fetch_token(token_url, client_secret=client_secret, authorization_response=redirect_response)
print(f'Access Token: {token["access_token"]}')
通过以上步骤,您可以从单个eBay开发人员帐户访问多个商店,并有效地管理多个店铺的API访问权限。
领取专属 10元无门槛券
手把手带您无忧上云