我们可以使用ASK SDK for python中的函数get_account_linking_access_token()来获取用于帐户链接的用户令牌
并存储在变量account_linking_token中。如果已完成帐户链接,则使用令牌获取用户数据,如下所示:
from ask_sdk_model.ui import SimpleCard
speech_output = ''
if account_linking_token is not None:
url = "https://api.amazon.com/user/profile?access_token{}"\
.format(account_linking_token)
user_data = requests.get(url).json()
# retrieve the required user info here and populate output
# speech_output = ...
else:
# output msg when account linking is not done
# speech_output = ...
# return this response from the intent handler function
response = handler_input.response_builder
.speak(speech_output)
.ask(reprompt)
.set_card(SimpleCard(speech_output))
.response
我们可以使用ASK SDK for python中的函数
get_account_linking_access_token()
来获取用于帐户链接的用户令牌 并存储在变量account_linking_token
中。如果已完成帐户链接,则使用令牌获取用户数据,如下所示:帐户链接对所有语言的工作方式相同,您应该熟悉
OAuth2
以在开发人员门户中配置帐户链接当您将帐户与您的技能链接时,来自该技能的每个后续请求都将包含一个访问令牌。然后可以使用此
accessToken
获取链接帐户的关联数据对于经过身份验证的用例,请始终检查
accessToken
是否可用,以及当请求中没有accessToken
表示用户未经过身份验证时,您可以向用户发送Account Link Card
。除了发送Account Link card
的代码外,链接帐户过程中不涉及任何编码发送账户链接卡:
在您的回复中,JSON包含
LinkAccount
卡要发送Python中的帐户链接卡
相关问题 更多 >
编程相关推荐