[英]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.