03-19-2024 01:25 AM - edited 03-19-2024 01:26 AM
Hi Team,
I have created a developer account and got the client id and client secret from that account. The account is approved by EBay
I am using the sandbox credentials now
I am calling the below API to get the auth code
https://auth.sandbox.ebay.com/oauth2/authorize?client_id=xxxxxxxxxxx&redirect_uri=https://xxxxxxxxxx...
Then calling the below passing the required values from postman like
grant_type as authorization_code,
code,
redirect_url
Authorization header has Base64encoded client_id:client_secret
https://api.sandbox.ebay.com/identity/v1/oauth2/token
But I am getting the below error
{
"error":"invalid grant",
"error_description":"The provided authorization grant code is invalid or issued to another client"
}
When we use the grant_type as client_credentials, we are receiving the token
Please let me know what needs to be done to get the access and refresh token
Thanks
03-20-2024 02:57 PM - edited 03-20-2024 02:59 PM
Hi @nock_0
The authorization code returned by eBay is URL-encoded. This value must be URL-encoded when you pass the value in the code
parameter of the authorization code grant request. However, if the method you use to make the request URL-encodes the values you pass, then you must URL-decode the authorization code before using it the authorization code grant request.
cURL code snippet for the step Exchanging the authorization code for a User access token:
curl --location 'https://api.ebay.com/identity/v1/oauth2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Basic B64-encoded-oauth-credentials' \
--data-urlencode 'grant_type=authorization_code' \
--data-urlencode 'redirect_uri=RuName-value' \
--data-urlencode 'code= authorization code decoded/encoded value(as per the method you use)'