Closed rdkgit closed 5 years ago
After much trial and error, I was able to get Amazon account linking working in my alexa-app based skill hosted on my own website.
Here is a snippet of code I added to my app.launch intent: ` if (req.data.session.user.accessToken == undefined) { console.log("Launch: no access token; not authenticated"); res.linkAccount(); } else { var amazonProfileURL = 'https://api.amazon.com/user/profile?access_token='; amazonProfileURL += req.data.session.user.accessToken; var done = false;
request(amazonProfileURL,function(error,response,body) {
if (response.statusCode == 200) {
var profile = JSON.parse(body);
message = "Hello "+profile.name.split(" ")[0];
res.say(message);
console.log("Logged in as "+profile.name+" email "+profile.email);
// do something with the email address like match it against internal list of users,
// etc.
}
done = true;
}); // request
deasync.loopWhile(function() { return !done; });
} // if else '
Hi!
I'm using the alexa-app-server as a basis for my alexa skill. I'm trying to implement Amazon account linking.
Do you have any pointers to how to integrate amazon account linking within your framework?
Also, how does the alexa session object fields map to the json request and response objects that are passed to the intents?
I've been reading the amazon documentation and various docs via Google and am unsure how to proceed. I've set up my security profile and got all of that squared away. Now, I want to prompt the user to login and I want to figure out what fields to access in the req and res objects.
Thanks,
Bobby