question

yospermtest avatar image
0 Likes"
yospermtest asked

Grant type in request is not supported by the authorization server

Hi, I'm trying to get my access token but I've got the following error description: { "error": "unsupported_grant_type", "error_description": "grant type in request is not supported by the authorization server" } I follow [this][1] article for "Using a refresh token to update a User access token" but it doesn't work to me. I already try to find a solution in the web so this is what I did so far (Using postman): Header: 1. set `Content-Type` to `application/x-www-form-urlencoded` 2. Set `Authorization` to `Basic Base64 encoded (<client_id>:<client_secret>)` I know this is the right Authorization since it already worked. Body (under x-www-form-urlencoded type): 1. I tried to set `grant_type ` to both 'authorization_code`and `refresh_token` 2. New `refresh_token` was generated by following [this][2] guide. 3. Scope was set to ` https://api.ebay.com/oauth/api_scope` Please advice me what am I doing wrong and how can I fix it, Thank! [1]: https://developer.ebay.com/api-docs/static/oauth-refresh-token-request.html [2]: https://developer.ebay.com/api-docs/static/oauth-consent-request.html
oauthtoken renewgrant_type
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.

tutrk52 avatar image
0 Likes"
tutrk52 answered

@yospermtest have you solved the issue? I am dealing the same issue right now.

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.

tutrk52 avatar image
0 Likes"
tutrk52 answered

It passed one year over the question but no answer. I think this community does not working well.

· 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,Have you solved the problem?

0 Likes 0 ·
lihuc_99 avatar image
0 Likes"
lihuc_99 answered

I met the same error


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.

ansl9377 avatar image
0 Likes"
ansl9377 answered

Any luck guys? I got the same error on Sandbox :( I replicated in postman so I can share the CURL request and response:

curl -L -X POST 'https://api.sandbox.ebay.com/identity/v1/oauth2/token' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Authorization: Basic QlVRTGltaXQtQlV.....YmZmZi0yZDBj'
--data-raw '{
 "grant_type":"authorization_code",
 "code": "v^1.1#i^1#p^3#f^0.....TI4NA=="
}'

I get a 400 bad request reply:

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

No idea what to do now as I have been following the docs to the letter.

Note: I released my code live and I am getting the same error in production, so this is NOT a sandbox issue.

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.

ansl9377 avatar image
0 Likes"
ansl9377 answered

@sagar_developersupport I have seen you answered some similar questions, any chance you can take a look at the above?

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.

alvisinwales avatar image
0 Likes"
alvisinwales answered

This is how I do it using CURL.

To get the first access token and its associated refresh token:

C:\curl.exe -k -X POST "https://api.ebay.com/identity/v1/oauth2/token"
-H "Content-Type: application/x-www-form-urlencoded"
-H "Authorization: Basic XXXXXXXXX...XXXXXXXXX
-d "@C:\FINOUT.txt"
-o C:\TEMPCURLOUT.txt

The input file FINOUT.txt contains
grant_type=authorization_code&code=v%5E1...VeMjYw&redirect_uri=XXXXXXXXX

The response goes into the file TEMPCURLOUT.txt. The refresh token is saved for use as described below.

Then when this access token needs to be refreshed:

C:\curl.exe -k -X POST "https://api.ebay.com/identity/v1/oauth2/token"
-H "Content-Type: application/x-www-form-urlencoded"
-H "Authorization: Basic XXXXXXXXX...XXXXXXXXX"
-d "@C:\FINOUT2.txt"
-o C:\TEMPCURLOUT2.txt

The input file FINOUT2.txt contains
grant_type=refresh_token&refresh_token=v^1.1#i...=

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.

ansl9377 avatar image
0 Likes"
ansl9377 answered

@alvisinwales

I am actually use nodejs but as the ebay docs use CURL for examples I just replicated the issue in postman, however via axios or postman I get the same error.

Looks like more people are struggling with the same error: https://forums.developer.ebay.com/questions/42886/invalid-client-from-oauth-generate-token-api.html

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

In that case I don't know. All I can say is that I don't get this error.



1 Like 1 ·
ansl9377 avatar image
0 Likes"
ansl9377 answered

I have submitted a support request with the above.

I DID manage to get this all working via the NodeJS SDK, so I know my credentials are working.

Hopefully support can help get my AXIOS requests working.

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 @ansl9377,

You need pass grant_type and code value as a form data in the request. Please try to execute the call with form data instated of raw data. Getting a user access token is a 3 step process. Please see all of the steps below:

- 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

- 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

- 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

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.