question

mattcheah avatar image
mattcheah asked

Where is the access token?

My apologies for asking what seems like such an elementary question, but the i've filled in all of the info to link to a user's google account, but I have no idea where the access token is returned. In the documentation about account linking (https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/linking-an-alexa-user-with-a-user-in-your-system) it says "In the JSON, the access token is available in the accessTokenproperty of the user object in the request:"

I'm using Node with the alexa-sdk.

exports.handler = function(event, context, callback) {
...
console.log("event request: ", event.request); 
// => { type: 'LaunchRequest',
// requestId: 'EdwRequestId.c1ac173a-038a-4e8a-9486-1be69ff583d7',
// timestamp: '2017-04-23T03:18:11Z',
// locale: 'en-US' }

If this is the request object that the article is referring to, there is no user object and no accessToken to be found. Thanks for your help!

alexa skills kitaccount linkingsdknode_js
10 |5000

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

1 Answer

GadgetChannel avatar image
GadgetChannel answered

The user object is under "session" and not "request" so you should use event.session.user.accessToken

4 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 for your response. The only thing I have in my event.session.user is a userId:

{ userId: 'amzn1.ask.account.AELHDFIIV4S[etc etc]' }

Does this mean that the access token is not being granted? How would I debug that? Thanks so much for your help.

0 Likes 0 ·

Have you actually linked your account? Also, If you are using the Service Simulator then this won't include the access token. You will need to use an actual device or the echosim.io site to test it.

0 Likes 0 ·

got it, thanks! Yes, it would have been smart for me to try to log in first. Much appreciated.

0 Likes 0 ·

How do i revoke an access token from session? I removed the permissions given to the application from the Amazon Account, but yet the skill can access the Account

0 Likes 0 ·