![](/img/trans.png)
[英]Android Microsoft Authentication Library (MSAL) : Facing issue in token expiry handling, how to refresh token using MSAL Android SDK
[英]How to get refresh token using Microsoft Authentication Library (Msal) in android
我正在嘗試使用Microsoft Single Sign on(使用此處提供的MSAL實現)登錄到我的android應用程序。
在onCreate中
mApp = new PublicClientApplication(this.getApplicationContext(), API.CLIENT_ID, API.AUTHORITY);
當用戶按下“使用Microsoft登錄”選項時,我將調用該方法以獲取令牌
mApp.acquireToken(this, getResources().getStringArray(R.array.msal_scopes), getAuthInteractiveCallback());
在onActivityResult中處理重定向請求后,我在回調中獲取身份驗證響應為
private AuthenticationCallback getAuthInteractiveCallback() {
return new AuthenticationCallback() {
@Override
public void onSuccess(AuthenticationResult authenticationResult) {
/* Successfully got a token, use it to call a protected resource */
accessToken = authenticationResult.getAccessToken();
Log.d("AuthSuccess"," "+accessToken);
}
@Override
public void onError(MsalException exception) {
/* Failed to acquireToken */
Log.d("AuthFail"," "+exception.getMessage());
if (exception instanceof MsalClientException) {
/* Exception inside MSAL, more info inside MsalError.java */
} else if (exception instanceof MsalServiceException) {
/* Exception when communicating with the STS, likely config issue */
}
}
@Override
public void onCancel() {
/* User canceled the authentication */
}
};
}
問題是, AuthenticationResult
對象提供access token
,但不提供refresh token
。 該對象根本沒有刷新令牌作為其參數之一。 我是否還需要進一步調用另一種方法來獲取刷新令牌? 如何使用MSAL從Microsoft單一登錄獲取訪問和刷新令牌?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.