I have spent countless hours just trying to get past LWA to no avail. I've whitelisted my URLs. I've conformed my serial to the regex. I've encoded my fields. I've done everything I've found in the discouraglingly scant DRS info I've been able to locate in docs, forums, etc. I can authorize no problem with profile scope. But the dash:replenish scope seems to just break everything. Here's example JS:
<!doctype html> <html class="no-js" lang="en"> <head> <meta charset="utf-8"> <title>lwa-example</title> </head> <body> <div id="amazon-root"></div> <script type="text/javascript"> window.onAmazonLoginReady = function() { amazon.Login.setClientId('amzn1.application-oa2-client.d1c6352332154272b75adfa65a6031f5'); var options = new Object(); var scope = ('dash:replenish'); var scope_data = new Object(); scope_data['dash:replenish'] = {"device_model":"e2baabee-39a8-4634-8be9-8b104d5db906","serial":"123456"}; options['scope_data'] = scope_data; options['scope'] = scope; options['response_type'] = 'code'; amazon.Login.authorize(options, "https://ishotjr.github.io/lwa-example/drs-handle-login.html"); }; (function(d) { var a = d.createElement('script'); a.type = 'text/javascript'; a.async = true; a.id = 'amazon-login-sdk'; a.src = 'https://api-cdn.amazon.com/sdk/login1.js'; d.getElementById('amazon-root').appendChild(a); })(document); </script> <p>lwa-example - DRS</p> </body> </html>
Try it here:
https://ishotjr.github.io/lwa-example/drs.html
The result is:
https://ishotjr.github.io/lwa-example/drs-handle-login.html?error_description=An+unknown+scope+was+requested&error=invalid_scope
Here's a manually constructed URL instead:
Same result:
https://ishotjr.github.io/lwa-example/drs-handle-login.html?error_description=An+unknown+scope+was+requested&error=invalid_scope
I was really looking forward to playing with the DRS functionality, but the amount of time I've spent just trying to get a basic PoC (not) working makes me want to Dash (pun intended) my brains out. I've found the documentation to be needlessly obtuse and lacking critical details (for example, use of amazon.Login.authorize in the docs completely fails to detail the required amazon-root functionality i.e. amazon.Login.* aren't even available if the example code from the docs is used directly).
A simple demo repo containing a "starter" version of the web-based functionality would have been immensely helpful in trying to figure all of this out. The extensive configuration is nicely explained, but in terms of actually getting code running, I feel somewhat abandoned. Elsewhere in the Amazon ecosystem, I've built Alexa apps based on getting started blog posts, and made my own Rasperry Pi-based Echo from a community-supported GitHub repo. DRS has been a comparatively poor experience with few examples, obtuse docs, and no exposure outside of this tiny community (e.g. Stack Overflow or enthusiast blog posts to cover the gaps). Bummer. :(