[英]Alexa Account Linking - What to do if access token linked is expired? I am using Implicit grant flow
I am trying to use Implicit grant flow for alexa account linking.我正在尝试使用隐式授权流程进行 alexa 帐户链接。 My access token is valid only for one year.
我的访问令牌的有效期仅为一年。
In your API check if the access token is still valid.在您的 API 中检查访问令牌是否仍然有效。 If it is not then send an account linking card and tell the user that they need to check their Alexa app to relink their account.
如果不是,则发送帐户链接卡并告诉用户他们需要检查他们的 Alexa 应用程序以重新链接他们的帐户。 Here's how you send an Account Linking card using the Alexa Skills Kit SDK for Node.js (v2) (see the withLinkAccountCard() call):
以下是使用适用于 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.
// ...
}
}
};
https://developer.amazon.com/en-US/docs/alexa/custom-skills/include-a-card-in-your-skills-response.html#define-a-card-for-use-with-account-linking https://developer.amazon.com/en-US/docs/alexa/custom-skills/include-a-card-in-your-skills-response.html#define-a-card-for-use-with-帐户关联
The user now needs to re-link the account and get the new access token.用户现在需要重新链接帐户并获取新的访问令牌。
If you need refresh token then use the Authorization Code Grant instead of Implicit Grant.如果您需要刷新令牌,请使用授权代码授权而不是隐式授权。
Hope this helps!希望这可以帮助!
If you are using Implicit Grant, there is no Refresh Token.如果您使用的是隐式授予,则没有刷新令牌。 What you suppose to do, when the token expire, display card to redirect to your Authorization Server.
你想做什么,当令牌过期时,显示卡重定向到你的授权服务器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.