question

thedavishouseoffashion avatar image
0 Likes"
thedavishouseoffashion asked

Error 21916984: Invalid IAF token (Python SDK)

I have been using the ebaysdk library as found on pypi. I have been trying to access the ItemIDs from a multivariationlisting like this:

from ebaysdk.trading import Connection as trading
def trd():
    try:
        api = trading(config_file = 'ebay.yaml')
        response = api.execute('GetItem', {'ItemGroupID': 164792568847})
        
        print(response.dict())
        print(response.reply)

    except ConnectionError as e:
        print(e)
        print(e.response.dict())


t = trd()

The error that I keep getting (referenced above) says:

ConnectionError: 'GetItem: Class: RequestError, Severity: Error, Code: 21916984, Invalid IAF token. IAF token supplied is invalid. '

I understand that this is telling me that I don't have a valid OAuth token, but I do not understand how, nor what I am supposed to do to resolve this using the conventions of the python sdks. I have continued to go to the Ebay developers ->User Tokens page and click the Get OAuth Application Token button to get my token, that I then manually paste over the old one in my ebay.yaml file as a string. I have seen on other posts, people using xml have usually been referencing the token wrong and found a way to rewrite their code, but I am looking for a way to do this in python, which should not have these issues as it is built on top of the xml api (assumed to be written correctly).

oauth2ebaysdk-pythoniafx-ebay-api-iaf-token
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
sagar_developersupport avatar image
0 Likes"
sagar_developersupport answered

Hi @thedavishouseoffashion ,

X-EBAY-API-IAF-TOKEN header supports the use of OAuth tokens for user authorization.

To authorize the request, supply a valid User access token for the value of this header. For details on User access tokens, see OAuth access tokens.

Ref: https://developer.ebay.com/api-docs/static/oauth-authorization-code-grant.html

Here you are using a Application access token in the request while you need to use "User access token" in the request.

To know more about how you can get the user access token from eBay UI, please go through the link given below.

Ref: https://developer.ebay.com/api-docs/static/oauth-ui-tokens.html

Best Regards ,
eBay Developer Support

10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.