简体   繁体   English

如何在 Flutter 应用程序中从 Azure 获取有效的 RS256 令牌?

[英]How to get a valid RS256 token from Azure in a Flutter app?

I'm doing a Flutter app for iOS and Android, and I need to use authentification to access to the main content.我正在为 iOS 和 Android 做一个 Flutter 应用程序,我需要使用身份验证才能访问主要内容。

For that I used this pubdev package (aad_oauth), and it works very well.为此,我使用了这个 pubdev package (aad_oauth),它运行良好。 I need to get the token provided by Azure to send it to my API to authenticate my user.我需要获取 Azure 提供的令牌,将其发送到我的 API 以验证我的用户。

I used this method:我用了这个方法:

    var token = await oauth.getAccessToken();

But the token is considered invalid even by my API then by https://jwt.io/ with the error "invalid signature" but works in the Flutter app.但是即使我的 API 然后https://jwt.io/也认为令牌无效,错误为“无效签名”,但在 Flutter 应用程序中有效。

Here is a censored screen of jwt.io:这是 jwt.io 的截屏:

在此处输入图像描述

Did someone knows how to get a valid token to send it after?有人知道如何获得有效令牌以在之后发送吗?

The invalid signature thrown by jwt.io is well known. jwt.io 抛出的无效签名众所周知。 You will need to manually obtain and set the Azure AD signing certificate content.您将需要手动获取并设置 Azure AD 签名证书内容。 Follow the steps detailed in USING JWT.IO TO VERIFY THE SIGNATURE OF A JWT TOKEN.按照使用 JWT.IO 中详述的步骤验证 JWT 令牌的签名。

Regarding validation at the API, you may have to fine-tune its token validation routine.关于 API 的验证,您可能需要微调其令牌验证例程。 This varies depending on the platform or library used for such end.这取决于用于此类目的的平台或库。 you can find samples for Microsoft backed libraries here .您可以在此处找到 Microsoft 支持的库的示例。

For more information on recommended validation please take a look to Validate tokens.有关推荐验证的更多信息,请查看验证令牌。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我从 Flutter 应用程序中的开发人员控制台获得有效的客户端 ID 时,如何使用 Google 登录 Package 获取有效的服务器身份验证令牌? - How to get valid Server Auth Token using Google Sign In Package when I have a valid client ID from developers console in Flutter app? 如何在 flutter 应用程序中获取 iOS 设备令牌 - How to get iOS device token in flutter app 我如何在 flutter 应用程序中设置令牌并在 flutter web 中获取它? - How can i set a token in flutter app and get it in flutter web? 如何在颤振中从服务器获取令牌? - How to get token from server in flutter? Flutter - 如何刷新 Firebase 的应用令牌 - Flutter - how to get refreshed Firebase's app token 如何在颤振应用程序中获取 Firebase 安装身份验证令牌? - How to get firebase installation auth token in flutter app? 如何获取flutter中的device token - How to get the device token in flutter 如何显示来自 get api with token in flutter 的数据 - how to show data from get api with token in flutter 如何在颤动中获取设备令牌 - How to get device token in flutter 如何从 Flutter 上的 Firebase Auth 获取用户 ID 令牌更改 - How to get user ID token changes from Firebase Auth on Flutter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM