用于Amazon Alexa中的帐户链接的示例python代码 [英] Sample python code for Account Linking in Amazon Alexa

查看:253
本文介绍了用于Amazon Alexa中的帐户链接的示例python代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在哪里可以找到Amazon Alexa中用于帐户链接的示例Python代码。我只能在这里获取文档。

Where can i find the sample Python code for Account linking in Amazon Alexa. I was only able to get the documentation here.

> https://developer.amazon.com/docs/account-linking/understand-account-linking.html

请帮助我!

推荐答案

帐户链接对所有语言均以相同的方式运行,您应该熟悉 OAuth2 在开发人员门户中配置帐户链接。

Account linking works the same way for all languages and you should be familiar with OAuth2 to configure account linking in developer portal.


用户可以通过两种方式链接帐户:

Users can link account in two ways:


  1. 在启用技能的同时从Alexa应用程序中的技能详细信息卡。

  2. 在发出需要身份验证的请求后,从Alexa应用程序中的链接帐户卡中。


当您将某个帐户与您的技能相关联时,该技能的每个后续请求都将包含一个访问令牌。然后,您可以使用此 accessToken 获取关联帐户的关联数据。

When you link an account with your skill, every subsequent request from the skill will include an access token. You can then use this accessToken to get associated data for linked account.

"session": {
        "new": true,
        "sessionId": "amzn1.echo-api.session.xxxxxxxxxxx",
        "application": {
            "applicationId": "amzn1.ask.skill.xxxxxxxxxx"
        },
        "user": {
            "userId": "amzn1.ask.account.xxxxxxx",
            "accessToken": "xxxxxxxxxxxxxx"

对于经过身份验证的用例,请始终检查 accessToken 可用,并且在请求中没有 accessToken 时,这意味着用户未通过身份验证,您可以向用户发送帐户链接卡。除了发送帐户链接卡的代码外,链接帐户过程中不涉及任何编码。

For an authenticated usecase, always check whether the accessToken is available and when there is no accessToken in the request that means that the user is not authenticated and you can send the user an Account Link Card. Except for the code to send an Account Link card there is no coding involved in link-an-account process.

要发送帐户链接卡

在您的响应JSON中包括 LinkAccount

In your response JSON include LinkAccount card

...
            "outputSpeech": {
                "type": "SSML",
                "ssml": "<speak> Please link your account </speak>"
            },
            "card": {
                "type": "LinkAccount"
            }
...

这篇关于用于Amazon Alexa中的帐户链接的示例python代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆