For account linking I wanted to use auth code grant. But im not able to understand from the given tutorials I want to fetch few user details such as DOB etc from alexa user.
1) Once the skill is enabled, it will ask for permission to access profile.
i.e URL = https://www.amazon.com/ap/oa/
2) User needs to login with amazon.
3) On successful login, user need to be redirected to our own heroku webpage, to enter few form details. URL = https://www.amazon.com/ap/oa/?redirect_uri=http://example.heroku.com/
4) After redirecting my URL looks like https://Example.heroku.com?code=XXXX&state=XXXX After entering the form details user click submit, where i mentioned the action as the https://layla.amazon.com/api/skill/link/XXXXXXXX?code=XXX&state=XXX
5) Account linking gets successfull but i m not getting the access token. Its only visible in the skill. I need that in my webpage to store the details agnaist each user.
6) Before redirecting If i use POST to https://api.amazon.com/auth/o2/token i get access token and refresh token as response but after that im not able to redirect https://layla.amazon.com using code and state. So, If i redirect first im not able to POST to api.amazon.com i get error as "error_description": "The request has an invalid grant parameter : code", I hope the code can only be used once.
Can somebody please let me know, how can I achieve this