question

thegadgetlystore avatar image
0 Likes"
thegadgetlystore asked

Sending messages and renewing token

Hey all so i have 2 questions as i cant seen to find them on the Docs. Im also using Python :D

First i cant find anything on how to send a message to a buyer.

Second my OAuth keeps expiring and i cant see to use my Auth'n'Auth token. is there a way of renewing my OAuth token in the background.

Here is my code so far :D

def EbayToken():
    client_id = "#"
    client_secret = "#"
    encodedData = base64.b64encode(bytes(f"{client_id}:{client_secret}", "ISO-8859-1")).decode("ascii")
    authorization_header_string = f"Authorization: Basic {encodedData}"

    headers = {"Authorization": "Basic " + encodedData, "Content-Type": "x-www-form-urlencoded"}

    data = {
        'grant_type': '#',
        ' scope': 'https://api.ebay.com/oauth/api_scope/sell.account'
    }

    response = requests.post('https://api.ebay.com/identity/v1/oauth2/token', headers=headers, data=data)
    print(response)
    print (response.content)

Thanks all :D

api login
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.

sagar_developersupport avatar image
0 Likes"
sagar_developersupport answered

Hi simong93,

We have the following comments for you:

1.) You can use the calls of Trading API for Buyer and seller communication. please go through the link mentioned below to know about the calls.

Ref: https://developer.ebay.com/devzone/xml/docs/reference/ebay/CommunicationIndex.html

2.) An user access token is valid for two hours from the time it was generated. For continued access after the token expires, you must mint a new token using the associated refresh token. When you mint a new User access token, the access token is returned along with a refresh token, which you can use to renew the User access token for the associated user.

Ref: https://developer.ebay.com/api-docs/static/oauth-refresh-token-request.html

Best Regards,
eBay Developers Support

· 1
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.

Ive been reading the Access token docs and still cant get it to work. I think ove got a bit further now but all its returning is:-

<Response [500]>
b''

Do you have an example that works i can use please :D

This is my new code. it might help someone else.


0 Likes 0 ·
sagar_developersupport avatar image
0 Likes"
sagar_developersupport answered

Hi @thegadgetlystore,

Getting a user access token is a 3 step process. Please see all of the steps below:
1. You need to construct an HTML request that will redirect the user to your application's Grant Application Access page for a getting user consent.

Ref: https://developer.ebay.com/api-docs/static/oauth-consent-request.html

2. After successfully getting a user consent, you will get an authorization code returned by the consent request URL. You can use this authorization code for getting a User access token.
Ref: https://developer.ebay.com/api-docs/static/oauth-auth-code-grant-request.html

3. An user access token is valid for two hours from the time it was generated. For continued access after the token expires, you must mint a new token using the associated refresh token.
Ref: https://developer.ebay.com/api-docs/static/oauth-refresh-token-request.html

Ref: https://developer.ebay.com/api-docs/static/oauth-authorization-code-grant.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.