简体   繁体   English

Alexa 帐户链接 - 如果链接的访问令牌已过期怎么办? 我正在使用隐式授权流程

[英]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.我的访问令牌的有效期仅为一年。

  1. How to ask the user to login again to get the new access token?如何要求用户再次登录以获取新的访问令牌?
  2. Can I share refresh token instead of access token with Amazon?我可以与亚马逊共享刷新令牌而不是访问令牌吗?

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.jsAlexa 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.

相关问题 AWS Cognito和Alexa帐户链接的正确访问令牌URI是什么? - What is the correct Access Token URI for AWS Cognito and Alexa account linking? Alexa帐户与Cognito关联 - Alexa Account Linking with Cognito Alexa中的帐户关联 - Account Linking In Alexa 使用 AWS Cognito 托管 UI(代码授权)验证后,我该如何处理令牌? 后续 API 调用没有令牌 - Using AWS Cognito Hosted UI (Code Grant) what do I do with the token once it is verified? Subsequent API Calls do not have the token 使用 ECS 中的服务相关角色授予对另一个账户中 AWS 资源的访问权限 - Grant access to AWS resources in another account using a service-linked role in ECS Alexa帐户与Google API关联 - Alexa account linking with google API 如何使用简单的 s3 存储桶策略授予对加密存储桶的跨账户访问权限? - How do I grant cross account access to an encrypted bucket with a simple s3 bucket policy? 被黑的 AWS 账户 - 我如何访问/删除他们创建的关联账户? - Hacked AWS account - how do I access/delete linked accounts that they have created? Alexa提供了您需要发送帐户链接卡的反馈 - Alexa is giving feedback that you need to send account linking card 账号关联azure AD后如何从alexa获取accesstoken - How to get the accesstoken from alexa after account linking with azure AD
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM