I'm recently trying to integrate Login With Amazon (LWA) with my website by following this instruction. However, when retrieving token by calling amazon.Login.retrieveToken(), I kept getting error as:
"oauth error (retrieveToken) UnsupportedOperation: Cookie amazon_Login_pkce_params not found. Cannot retrieve token without cookie."
Here is the code. I didn't find anything wrong, especially I do add "options.pkce = true;". Anyone please help me find what I missed? Thanks!
<div id="amazon-root"></div> <script type="text/javascript"> window.onAmazonLoginReady = function() { amazon.Login.setClientId('amzn1.application-oa2-client.<Hide My Client Id Here>'); }; (function(d) { var a = d.createElement('script'); a.type = 'text/javascript'; a.async = true; a.id = 'amazon-login-sdk'; a.src = 'https://assets.loginwithamazon.com/sdk/na/login1.js'; d.getElementById('amazon-root').appendChild(a); })(document); </script> <a href id="LoginWithAmazon"> <img border="0" alt="Login with Amazon" src="https://images-na.ssl-images-amazon.com/images/G/01/lwa/btnLWA_gold_156x32.png" width="156" height="32" /> </a> <script type="text/javascript"> document.getElementById('LoginWithAmazon').onclick = function() { setTimeout(window.doLogin, 1); return false; }; window.doLogin = function() { options = {} options.scope = 'profile'; options.pkce = true; amazon.Login.authorize(options, function(response) { if ( response.error ) { alert('oauth error (authorize) ' + response.error); return; } amazon.Login.retrieveToken(response.code, function(response) { if ( response.error ) { alert('oauth error (retrieveToken) ' + response.error); return; } alert('Access Token: ' + response.access_token); }); }); }; </script>