Java源码示例:com.microsoft.identity.client.exception.MsalServiceException

示例1
@Override
public void onError(MsalException exception) {
    // Check the exception type.
    if (exception instanceof MsalClientException) {
        // This means errors happened in the sdk itself, could be network, Json parse, etc. Check MsalError.java
        // for detailed list of the errors.
        showMessage(exception.getMessage());
        showConnectErrorUI(exception.getMessage());
    } else if (exception instanceof MsalServiceException) {
        // This means something is wrong when the sdk is communication to the service, mostly likely it's the client
        // configuration.
        showMessage(exception.getMessage());
        showConnectErrorUI(exception.getMessage());
    } else if (exception instanceof MsalUiRequiredException) {
        // This explicitly indicates that developer needs to prompt the user, it could be refresh token is expired, revoked
        // or user changes the password; or it could be that no token was found in the token cache.
        AuthenticationManager mgr = AuthenticationManager.getInstance();


        mgr.callAcquireToken(ConnectActivity.this, this);
    }
}
 
示例2
/**
 * Get an AuthenticationCallback object to handle the result of the Microsoft login
 */
private AuthenticationCallback getAuthInteractiveCallback() {
    return new AuthenticationCallback() {
        @Override
        public void onSuccess(AuthenticationResult authenticationResult) {
            /* Successfully got a token, use it to call a protected resource */
            Log.e(TAG, " MSA signInResult:= " + authenticationResult.getAccessToken());
            mAuthResult = authenticationResult;
            mSignInActivity.getProgressBar().setVisibility(View.VISIBLE);
            callGraphAPI();
        }

        @Override
        public void onError(MsalException exception) {
            /* Failed to acquireToken */

            if (exception instanceof MsalClientException) {
                /* Exception inside MSAL, more info inside MsalError.java */
                Log.e(TAG, "MSA signInResult: error =" + exception.getMessage());
            } else if (exception instanceof MsalServiceException) {
                /* Exception when communicating with the STS, likely config issue */
                Log.e(TAG, "MSA signInResult:error =" + exception.getMessage());
            }
        }

        @Override
        public void onCancel() {
            /* User canceled the authentication */
        }
    };
}
 
示例3
@Override
public void onError(MsalException e) {
    e.printStackTrace();

    //Show the localized message supplied with the exception or
    //or a default message from the string resources if a
    //localized message cannot be obtained
    String msg;
    if (null == (msg = e.getLocalizedMessage())) {
        msg = getString(sign_in_err);
        Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
    } else {
        mDiagnosticsTxt.setText(msg);
        mDiagnosticsLayout.setVisibility(VISIBLE);
    }

    if (e instanceof MsalClientException) {
        // This means errors happened in the sdk itself, could be network, Json parse, etc. Check MsalError.java
        // for detailed list of the errors.

        Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();

    } else if (e instanceof MsalServiceException) {
        // This means something is wrong when the sdk is communication to the service, mostly likely it's the client
        // configuration.
        Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();

    } else if (e instanceof MsalUiRequiredException) {
        // This explicitly indicates that developer needs to prompt the user, it could be refresh token is expired, revoked
        // or user changes the password; or it could be that no token was found in the token cache.
        AuthenticationManager mgr = AuthenticationManager.getInstance();
        mgr.callAcquireToken(SignInActivity.this, this);
    }

}
 
示例4
@Override
public void onError(MsalException exception) {
    exception.printStackTrace();

    //Show the localized message supplied with the exception or
    //or a default message from the string resources if a
    //localized message cannot be obtained
    String msg;
    if (null == (msg = exception.getLocalizedMessage())) {
        msg = getString(signin_err);
        Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
    } else {
        mDiagnosticsTxt.setText(msg);
        mDiagnosticsLayout.setVisibility(VISIBLE);
    }
    if (exception instanceof MsalClientException) {
        // This means errors happened in the sdk itself, could be network, Json parse, etc. Check MsalError.java
        // for detailed list of the errors.

        Toast.makeText(this, exception.getMessage(), Toast.LENGTH_SHORT).show();

    } else if (exception instanceof MsalServiceException) {
        // This means something is wrong when the sdk is communication to the service, mostly likely it's the client
        // configuration.
        Toast.makeText(this, exception.getMessage(), Toast.LENGTH_SHORT).show();

    } else if (exception instanceof MsalUiRequiredException) {
        // This explicitly indicates that developer needs to prompt the user, it could be refresh token is expired, revoked
        // or user changes the password; or it could be that no token was found in the token cache.

        mAuthenticationManager.callAcquireToken( this);
    }
}