12-09-2023 03:53 PM
Hi fellows,
Hope to get some response about my issue which I am seeing regarding to "The client credentials grant flow".
I am stretching my head but can't find something reliable to get the valid response.
I am trying to get auth token for prod environment, to use it in my subsequent ebay API calls.
I am doing the following:
Creating post request to https://api.ebay.com/identity/v1/oauth2/token? api with this header:
Content-Type: application/x-www-form-urlencoded
Authorization: Basic <base 64 encoded clientId:secret>
and this body:
grant_type: client_credentials
scope: https%3A%2F%2Fapi.ebay.com%2Foauth%2Fapi_scope%20https%3A%2F%2Fapi.ebay.com%2Foauth%2Fapi_scope%2Fsell.marketing.readonly%20https%3A%2F%2Fapi.ebay.com%2Foauth%2Fapi_scope%2Fsell.marketing%20https%3A%2F%2Fapi.ebay.com%2Foauth%2Fapi_scope%2Fsell.inventory.readonly%20https%3A%2F%2Fapi.ebay.com%2Foauth%2Fapi_scope%2Fsell.inventory%20https%3A%2F%2Fapi.ebay.com%2Foauth%2Fapi_scope%2Fsell.account.readonly%20https%3A%2F%2Fapi.ebay.com%2Foauth%2Fapi_scope%2Fsell.account%20https%3A%2F%2Fapi.ebay.com%2Foauth%2Fapi_scope%2Fsell.fulfillment.readonly%20https%3A%2F%2Fapi.ebay.com%2Foauth%2Fapi_scope%2Fsell.fulfillment%20https%3A%2F%2Fapi.ebay.com%2Foauth%2Fapi_scope%2Fsell.analytics.readonly%20https%3A%2F%2Fapi.ebay.com%2Foauth%2Fapi_scope%2Fsell.finances%20https%3A%2F%2Fapi.ebay.com%2Foauth%2Fapi_scope%2Fsell.payment.dispute%20https%3A%2F%2Fapi.ebay.com%2Foauth%2Fapi_scope%2Fcommerce.identity.readonly%20https%3A%2F%2Fapi.ebay.com%2Foauth%2Fapi_scope%2Fcommerce.notification.subscription%20https%3A%2F%2Fapi.ebay.com%2Foauth%2Fapi_scope%2Fcommerce.notification.subscription.readonly
With this upper-mentioned request, I am always receiving invalid_scope.
Could you please help me understand what is wrong here?
I am getting my scope from "Application keysets" -> "Your eBay Sign-in Settings" -> "Your branded eBay Production Sign In (OAuth)" -> variable value for scope from the url and doing URL encoding.
Regards,
Razmik
12-09-2023 05:34 PM
The scopes that you are providing belong to the Authorization Code Grant Type, but you are trying to use them for a Client Credential Grant Type. The Authorization Code Grant requires the eBay user's authorization to access details within their account. The Client Credential Grant allows your application to access public data.
https://developer.ebay.com/api-docs/static/oauth-tokens.html
12-10-2023 05:43 AM
Thanks for getting back to me.
Understands, but in my application keys as a Client Credential Grant Type for prod environment i have
https://api.ebay.com/oauth/api_scope |
only this.
So when i am url encoding this and adding to my request i am receiving the same invalid_scope error.
What else can be wrong? 😞
12-10-2023 06:34 AM
also one more question please:
right now i am usign ebay browse api to list some ebay items in my ios application, and i amn using the token generated in the ebay portal directly, but this is expiring after 2 hours.
So i came up to this "Client credentials grant type" flow to update the token in my app periodically.
I wanted to check the token response from https://api.ebay.com/identity/v1/oauth2/token? is the same bearer token which i get from ebay portal right?
12-10-2023 10:11 AM
Hi @shipscript ,
So to bypass the scope issue, i tried to not supply scope at all.
Now when i dont supply scope parameter during request, i am receiving the application access token, but when i am adding this token to my call to browse API, i am receiving the following
{
"errors": [
{
"errorId": 1100,
"domain": "ACCESS",
"category": "REQUEST",
"message": "Access denied",
"longMessage": "Insufficient permissions to fulfill the request."
}
]
}
I think the problem is that i am skipping the scope when requesting the token, and with that token i am unable to use Browse API.
is my guess correct?
Thanks a bunch for helping.
12-10-2023 11:23 AM
For the Browse API to access public data, only one scope is needed for the Client credentials:
https://api.ebay.com/oauth/api_scope
Make sure that your programming language is correctly passing this information in the URL request. This data becomes part of a query string, so should look like one. Incorrect formatting has caused trouble for some. For instance:
grant_type=client_credentials
scope=https%3A%2F%2Fapi.ebay.com%2Foauth%2Fapi_scope
See this page:
https://developer.ebay.com/api-docs/static/oauth-client-credentials-grant.html
12-10-2023 11:30 AM
Many thanks @shipscript , i was supplying it as a request body, not a query param.
it worked, appreciate your help.
07-03-2024 03:29 AM - edited 07-03-2024 03:36 AM
Note that https://developer.ebay.com/api-docs/static/oauth-client-credentials-grant.html says nothing about query string, both params are shown in payload.
I have tested grant_type and scope in both query string and request body, grant_type works in both, scope only in query string.
scope can also be sent in request body with multipart/form-data header, but grant_type can not.
I have used Postman for testing, maybe the issue is in Postman interpretation of x-www-form-urlencoded.
02-24-2025 03:38 AM
Hi, are you still monitoring this.
I am having this same issue but not with postman.
I can't get access token due to invalid scope, but there is only one listed for client
credentials type, and it will not accept it.
03-30-2025 07:35 AM
Hi eBay Developer Team,
I am developing a custom website for my eBay store to display my live product listings using the Browse API.
However, I am getting an "invalid_scope" error when trying to authorize with this scope:
https://api.ebay.com/oauth/api_scope/buy.browse
My app details:
App ID (Client ID): MustafaB-sa-PRD-6dec84694-47e3ed03
RuName: Mustafa_Baykal-MustafaB-sa-PRD-kywosbcsp
Please enable access to the buy.browse scope for my production credentials.
Thank you very much!
04-02-2025 02:38 PM
Hello @boyntoyllc ,
It seems you are experiencing the "Invalid Scope" error because the scope https://api.ebay.com/oauth/api_scope/buy.browse you are using for authorization is not valid for the Browse API.
To address this issue, please ensure you use the appropriate scope for Browse API authorization.
Best Regards,
eBay Developer Support
04-07-2025 11:19 AM
Alright, I got the job done without the API. Thanks
04-07-2025 11:23 AM
I wanted to use the API to display my eBay store products on my website. However, it turned out to be a long and exhausting process. So instead, I wrote a script using AI for my products and pulled them to my website through Google Sheets.