![](/img/trans.png)
[英]How to get refresh token using Microsoft Authentication Library (Msal) in android
[英]msal+oauth - how to retrieve refresh token from android/flutter
我们正在开发一个应用程序,它可以预见多个使用 oauth 登录的 Microsoft 帐户。 我们正在使用这个 package
https://pub.dev/packages/msal_mobile#-readme-tab-
它包装了官方的微软库
https://github.com/AzureAD/microsoft-authentication-library-for-android
我知道该库不会直接公开刷新令牌,而是在后端刷新它。 但是,因为 flutter 库不允许多个登录帐户(最终因为用户可能从相关的 Microsoft 帐户在 Internet 上退出,因此也从应用程序中退出他的帐户之一)我们需要交换访问权限使用如下请求的带有刷新令牌的令牌:
POST /common/oauth2/v2.0/token HTTP/1.1 Host: https://login.microsoftonline.com Content-Type: application/x-www-form-urlencoded
client_id=...
&scope=... &code=OAAABAAAAiL9Kn2Z27UubvWFPbm0gLWQJVzCTE9UkP3pSx1aXxUjq3n8b2JRLk4OxVXr...
&redirect_uri=msauth://...
&grant_type=authorization_code
但是,为了这样做,我收到一个错误“ invalid_grant"
,描述如下:
> "AADSTS9002313: Invalid request. Request is malformed or invalid...”
而提供的 accessToken 似乎是正确的,并且它由 msal/flutter 库正确返回。 我们如何解决这个问题? 该应用程序似乎已在 azure 门户网站上正确设置。 如果这是 android 官方 msal 库的限制,您是否有任何提示如何添加该功能? 谢谢(托马斯)
I don't know too much about flutter, but if I remember correctly, for azure oauth, if you are trying to get a refresh token using the token endpoint, then you must request the scope of offline_access with that authorization_code grant type. 也许试试看。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.