question

Bcarbs avatar image
Bcarbs asked

Why am I receiving invalid_scope_data error?

The scope data list you provided is invalid for your request&error=invalid_scope_data

{"scope_data":{"dash:replenish":{"device_model":"eb9edf13-5a38-4d72-b7e5-37a788e144bf","serial":"arduino1","is_test_device":"true"}}}

Receiving the error invalid_scope_data when trying to request an authorization for LWA. Scope data field pasted above... Any idea what I might be missing or which fields are invalid?

https://www.amazon.com/ap/oa/client_id=amzn1.application-oa2-client.1d46c0b93......(abbreviatedclientID)&scope=dash%3Areplenish&scope_data=%7B%22scope_data%22%3A%7B%22dash%3Areplenish%22%3A%7B%22device_model%22%3A%22eb9edf13-5a38-4d72-b7e5-37a788e144bf%22%2C%22serial%22%3A%22arduino1%22%2C%22is_test_device%22%3A%22true%22%7D%7D%7D&response_type=code&redirect_uri=https%3A%2F%2Fwww.getpostman.com%2Foauth2%2Fcallback

login with amazondash replenishment service
3 comments
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thanks Bcarbs, I forwarded this to the Dash team, will post back when I have an answer. Thanks!

1 Like 1 ·

Hey Levon, just wanted to include this bit of information in the event it helps the Dash team!

https://www.amazon.com/ap/oa?client_id=amzn1.application-oa2-client.1d46c0b931e74813bda81d4e1c776b1c&scope=dash:replenish&{"scope_data":{"dash:replenish":{"device_model":"eb9edf13-5a38-4d72-b7e5-37a788e144bf","serial":"arduino123456789"}},"scope":"dash:replenish","response_type":"code"}&response_type=code&redirect_uri=https://www.getpostman.com/oauth2/callback

This url sort of worked, it seems the fact that my details were form-url-encoded in the body was causing the error. Including the scope_data json in the same format with all fields in plain text like the above managed to get me as far as the "grant permission to the app page.

Unfortunately though, once I choose to grant permission I receive a response that there was an error, but it's pretty vague...

It's actually the same exact error/response that Daniel is having here (Authorization request with scope=dash:replenish)

Thanks for all your help!

0 Likes 0 ·

Thanks for additional details, I have added them to the ticket. Will reply as soon as I hear back from the DRS team. Thanks!

1 Like 1 ·

1 Answer

Levon@Amazon avatar image
Levon@Amazon answered

Hi Bcarbs,

The main problem seems to be that you are making a malformed request. Here is how a valid request to LWA should look like:

/ap/oa?client_id=application-oa2-client.1d46c0b931e74813bda81d4e1c776b1c&scope=dash:replenish&scope_data={"dash:replenish":{"device_model":"eb9edf13-5a38-4d72-b7e5-37a788e144bf","serial":"arduino123456789"}}&response_type=code&redirect_uri=https://www.getpostman.com/oauth2/callback

Note, values such as e.g scope, scope_data etc. should be URLEncoded. So you should be calling URL looking like this:

/ap/oa?client_id=application-oa2-client.1d46c0b931e74813bda81d4e1c776b1c&scope=dash%3Areplenish&scope_data=%7B%22dash%3Areplenish%22%3A%7B%22device_model%22%3A%22eb9edf13-5a38-4d72-b7e5-37a788e144bf%22%2C%22serial%22%3A%22arduino123456789%22%7D%7D&response_type=code&redirect_uri=https%3A%2F%2Fwww.getpostman.com%2Foauth2%2Fcallback

Hope it helps.

2 comments
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

https://www.amazon.com/ap/oa?client_id=amzn1.application-oa2-client.6ece4f138f8c4a81bc904a0ec9b4018c&scope=dash%3Areplenish&scope_data=%7B%22dash%3Areplenish%22%3A%7B%22device_model%22%3A%22WCPAPER002%22%2C%22serial%22%3A%22wcpaper002001%22%7D%7D&response_type=code&redirect_uri=https%3A%2F%2Ftyeth.github.io%2FSmartDrawer%2Fredirect

Trying to similarly resolve the invalid scope issue....I get redirected but with error message in redirect URL.

If I change the second dash%3Areplenish with dash_replenish, it responds with error in scope data list as other people have mentioned, rather than the invalid scope error.

Any ideas?

0 Likes 0 ·

Hi Tyeth,

The correct scope is 'dash:replenish'. The other one, 'dash_replenish' is not a valid scope and will result in invalid scope error.

Regarding the request:

https://www.amazon.com/ap/oa?client_id=amzn1.application-oa2-client.6ece4f138f8c4a81bc904a0ec9b4018c≻ope=dash%3Areplenish≻ope_data=%7B%22dash%3Areplenish%22%3A%7B%22device_model%22%3A%22WCPAPER002%22%2C%22serial%22%3A%22wcpaper002001%22%7D%7D&response_type=code&redirect_uri=https%3A%2F%2Ftyeth.github.io%2FSmartDrawer%2Fredirect

Looks like some of the fields above (scope and scope_data) are not encoded correctly. Is it just a copy paste error? Once we have the correct request, we can forward it to LwA to take a look. Thanks!

0 Likes 0 ·