I'm building an application that utilizes eBay's Buy API to retrieve information about currently listed products. My issue is that the access token I obtain expires every 2 hours, and I need a refresh token to automatically generate new access tokens. I'm trying to obtain a refresh token, but I'm encountering an issue with the following API endpoint:
Endpoint: https://api.ebay.com/identity/v1/oauth2/token
I need to pass the following five parameters:
HTTP headers:
Content-Type = application/x-www-form-urlencoded
Authorization = Basic <B64-encoded-oauth-credentials>
Request body (wrapped for readability):
grant_type=authorization_code
code=<authorization-code-value>
redirect_uri=<RuName-value>
I'm using Postman to make this API call, and I've double-checked and confirmed that all the parameters are correctly set. However, I keep receiving the following error:
{
"error": "invalid_request",
"error_description": "request is missing a required parameter or malformed."
}
I've spent over two hours attempting to resolve this issue without success. Can someone please provide guidance on how to properly structure this request or identify any potential issues that could be causing this error?
ps: I am able to get my access token through grant_type=client_credentials
A few things to check: Did you check the box for "OAuth Enabled" on your eBay developer token settings page? https://developer.ebay.com/my/auth/?env=production&index=0&auth_type=oauth
Did you include a space between the word 'Basic' and the encoded credentials on the Authorization header? Also be sure you put the colon ':' between client_id and client_secret. I recommend using Postman's built in Basic auth handling.
Be sure the "body" option is set to 'x-www-form-urlencoded'. That will add the 'Content-Type' header for you. Finally, make sure your authorization code hasn't expired. It's only valid for about 5 minutes. I have it working in Postman, some screenshots attached to help:
