question

jewelryliquidation avatar image
0 Likes"
jewelryliquidation asked ·

Cannot get a User access token

Hi all, I'm trying to get a User Access token, but can't quite understand why it's not working. I've followed all the steps here https://developer.ebay.com/api-docs/static/oauth-authorization-code-grant.html but still not getting it. What I'm doing: 1) I get the user consent (I need it only for my own account) by going to ` https://auth.sandbox.ebay.com/oauth2/authorize?client_id={app-client-id-value}&redirect_uri={app-RuName-value}&response_type=code&scope={scopeList}` for scopeList I'm using a URL encoded string of scopes separated by a space. After going there and accepting, I'm redirected to a url with a parameter of "code". 2) I use that code value to send a POST request to ` https://api.ebay.com/identity/v1/oauth2/token` I use headers of Content-Type: application/x-www-form-urlencoded and Authorization: Basic *base64encoded("{clientID}:{clientSecret}")* For the body of the request I use: grant_type=authorization_code code={code-parameter-from-url in step 1} redirect_uri={RuName used in url to get the user consent in step 1} The response I get is always the same: **{ "error": "invalid_grant", "error_description": "the provided authorization grant code is invalid or was issued to another client" }** I've noticed that changing the grant_type to client_credentials returns an Application Access Token, but I don't understand why when I'm following the User Access token guide step-by-step. I'm using Postman to send all the requests, so it's not a programming error. Once I can get the flow to work, I can program it easily, but I'm stuck on getting the actual User Access token. Any help would be extremely appreciated. Thanks!
errortokentokenstoken erroruser tokeninvalid token
· 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.

Hi jewelryliquidation.

Probably your error is here:

"What I'm doing: 1) I get the user consent (I need it only for my own account) by going to ` https://auth.sandbox.ebay.com/oauth2/authorize?client_id={app-client-id-value}&redirect_uri={app-RuName-value}&response_type=code&scope={scopeList}` for scopeList I'm using a URL encoded string of scopes separated by a space."

"2) I use that code value to send a POST request to ` https://api.ebay.com/identity/v1/oauth2/token`"

Try to define this environment:

https://api.sandbox.ebay.com/identity/v1/oauth2/token

0 Likes 0 ·
gomo-9149 avatar image
0 Likes"
gomo-9149 answered ·

Hi @sagar_developersupport,

Thank you for your response. Really appreciate it.

I used the same process mentioned in the documentation you had provided, however I am getting the following error when making a call to the getCampaigns endpoint.

{ "errors": [ { "errorId": 1100, "domain": "ACCESS", "category": "REQUEST", "message": "Access denied", "longMessage": "Insufficient permissions to fulfill the request." } ]}

I have mentioned the scope needed to access this endpoint in Step 1 to get user consent and also when updating the access token using my refresh token.

https://api.ebay.com/oauth/api_scope/sell.marketing

Please can you advise me on how I can resolve this issue? Should I be adding more scopes?

Also, another issue I was facing in Postman was passing the scope in the body of the API call to update the access token. I was able to get the access token when the body is mentioned as

grant_type:refresh_token

refresh_token:v^1.1#i^1#r^1#p^3#I^3#f^0#t^Ul4MF85OjBDRTJFlDMjU5QkVDOUMxODRGDg4Nzk2NXzFfMSNFXjI2MA==

https://api.ebay.com/oauth/api_scope/sell.marketing

But not when it was mentioned as (this is the syntax provided in the documentation)

grant_type:refresh_token

refresh_token:v^1.1#i^1#r^1#p^3#I^3#f^0#t^Ul4xMF85OjBDRTJFRTlDMjU5QkVDOUMxODRGNDg4Nzk2NzZBOTE4XzFfMSNFXjI2MA==

scope: https://api.ebay.com/oauth/api_scope/sell.marketing

I tried the same thing using curl command online and it only worked when the word 'scope' was not mentioned in the body.

Thanks,

Gowri

·
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 @gomo-9149,

Please refer below docs to see how to get the User Access token , access tokens.

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

Ref: https://ebaydts.com/eBayKBDetails?KBid=5075

Best Regards ,
eBay Developer 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.

Hi Sagar,

Thanks for your response.

Please can you advise me on the issue I'm facing that I've mentioned in the answer section above?

Thanks,

Gowri

0 Likes 0 ·
gomo-9149 avatar image
0 Likes"
gomo-9149 answered ·

Hi. Were you able to figure this out? I am facing similar issues with getting the User Access token. I've done everything as mentioned in the documentation and got the code in the url response of Step 1. I used the same in Step 2 right away but I am getting the error

{ "error": "unsupported_grant_type", "error_description": "grant type in request is not supported by the authorization server"}

Would you happen to know how to solve this please?

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

I met the same mistake


{

"error": "unsupported_grant_type",

"error_description": "grant type in request is not supported by the authorization server"

}

0 Likes 0 ·

Have you solved the problem?

0 Likes 0 ·

Have you solved the problem?


0 Likes 0 ·

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.