How to define X-EBAY-API-IAF-TOKEN in python?
I'm new to this api and trying to access the shopping api with python. It requires me to set an HTTP header of
X-EBAY-API-IAF-TOKEN. How should I set it?
Currently I'm setting it like this:
```
api = Shopping(appid = PRODUCTION_APPLICATION_ID, config_file = None)
api.execute('GetSingleItem', {"itemId" : iid,
"X-EBAY-API-IAF-TOKEN" : OATH_TOKEN})
response = api.response_dict()
```
It's throwing me this error: ConnectionError: 'GetSingleItem: Class: RequestError, Severity: Error, Code: 1.33, Token not available in request.Token not available in request. Please specify a valid token as HTTP header., Class: RequestError, Severity: Error, Code: 10.1, Please specify a query!Please specify a query!'
sh0552
Posted 3 years ago·Last reply 3 years ago
1 comment
shipscript
·3 years agoUsing the Shopping API is a two step process, each requiring credentials.
The first step is to submit your base64 developer credentials (clientID:clientSecret) to generate a new OAuth token, which expires within 2 hours, or to refresh an expiring token that has been stored on your website for that purpose. eBay prefers that developers reuse a token until it expires, rather then generating a new token for each call.
https://developer.ebay.com/api-docs/static/oauth-client-credentials-grant.html
The second step is to make a call to the Shopping API using that token in the header.
X-EBAY-API-IAF-TOKEN : token_string
I have a fully working PHP example here, which may help you work through the logic and help to create the headers for both steps.
https://community.ebay.com/t5/Token-Messaging-Sandbox-related/Sample-PHP-for-generating-and-renewing-a-Shopping-token/td-p/33540297