cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

invalid_scope error

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

 

Message 1 of 13
latest reply
12 REPLIES 12

invalid_scope error

@razkarap_0 

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

 

ShipScript has been an eBay Community volunteer since 2003, specializing in HTML, CSS, Scripts, Photos, Active Content, Technical Solutions, and online Seller Tools.
Message 2 of 13
latest reply

invalid_scope error

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? 😞 

Message 3 of 13
latest reply

invalid_scope error

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?

Message 4 of 13
latest reply

invalid_scope error

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.

Message 5 of 13
latest reply

invalid_scope error

@razkarap_0 

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 

 

 

ShipScript has been an eBay Community volunteer since 2003, specializing in HTML, CSS, Scripts, Photos, Active Content, Technical Solutions, and online Seller Tools.
Message 6 of 13
latest reply

invalid_scope error

Many thanks @shipscript , i was supplying  it as a request body, not a query param.
it worked, appreciate your help.

Message 7 of 13
latest reply

invalid_scope error

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.

Message 8 of 13
latest reply

invalid_scope error

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.

Message 9 of 13
latest reply

invalid_scope error

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!

Message 10 of 13
latest reply

invalid_scope error

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

Message 11 of 13
latest reply

invalid_scope error

Alright, I got the job done without the API. Thanks

Message 12 of 13
latest reply

invalid_scope error

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.

Message 13 of 13
latest reply