[英]What is the correct Access Token URI for AWS Cognito and Alexa account linking?
[英]Alexa Account Linking - What to do if access token linked is expired? I am using Implicit grant flow
我正在尝试使用隐式授权流程进行 alexa 帐户链接。 我的访问令牌的有效期仅为一年。
在您的 API 中检查访问令牌是否仍然有效。 如果不是,则发送帐户链接卡并告诉用户他们需要检查他们的 Alexa 应用程序以重新链接他们的帐户。 以下是使用适用于 Node.js的Alexa Skills Kit SDK (v2)发送帐户关联卡的方法(请参阅 withLinkAccountCard() 调用):
const OrderCarIntentHandler = {
// ...
handle(handlerInput){
// This intent requires an access token so that we can get the user's
// Ride Hailer user profile with payment information.
// The access token is in the Context object. Access the
// request in the HandlerInput object passed to the
// handler.
var accessToken = handlerInput.requestEnvelope.context.System.user.accessToken;
if (accessToken == undefined){
// The request did not include a token, so tell the user to link
// accounts and return a LinkAccount card
var speechText = "You must have a Ride Hailer account to order a car. " +
"Please use the Alexa app to link your Amazon account " +
"with your Ride Hailer Account.";
return handlerInput.responseBuilder
.speak(speechText)
.withLinkAccountCard()
.getResponse();
} else {
// Use the token to access the user's profile. This should also verify that the
// token represents a valid Ride Hailer user.
// ...
}
}
};
用户现在需要重新链接帐户并获取新的访问令牌。
如果您需要刷新令牌,请使用授权代码授权而不是隐式授权。
希望这可以帮助!
如果您使用的是隐式授予,则没有刷新令牌。 你想做什么,当令牌过期时,显示卡重定向到你的授权服务器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.