【问题标题】:How to get refresh token using Microsoft Authentication Library (Msal) in android如何在 android 中使用 Microsoft 身份验证库 (Msal) 获取刷新令牌
【发布时间】:2018-03-12 06:14:46
【问题描述】:

我正在尝试使用 Microsoft Single Sign on 登录我的 android 应用程序,并使用 here 提供的 MSAL 实现。

在 onCreate 中

mApp = new PublicClientApplication(this.getApplicationContext(), API.CLIENT_ID, API.AUTHORITY);

当用户按下“Sign in with Microsoft”选项时,我调用获取token的方法

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 单点登录获得访问令牌和刷新令牌?!

【问题讨论】:

    标签: android single-sign-on


    【解决方案1】:

    【讨论】:

      猜你喜欢
      • 2016-10-17
      • 2021-01-03
      • 1970-01-01
      • 2020-08-05
      • 2017-11-08
      • 1970-01-01
      • 2019-08-30
      • 1970-01-01
      • 2021-10-15
      相关资源
      最近更新 更多