Why Google authentication token refresh is keep failing recently in Azure Mobile Apps SDK for Android RRS feed

  • Question

  • I have an android app implementing the azure mobile SDK (com. microsoft. azure: azure-mobile-android:3.5.1@aar)
    In my app I use the Google authentication method.
    The authentication had been working fine for nearly 2 years. For the last 10 days, my users cannot refresh their auth tokens, if the last refresh was made about 60 minutes or more ago. The refresh succeeds only if it is called sooner. If the refresh fails, as it does, I must force the user to sign-in again using the Google consent screen to get a new token. This was not happening before, as the tokens could be refreshed even days after the last refresh. What could be wrong?

    The users see this error message in their android device, if the refresh() is called more than about 1 hour after the last refresh:

    Google authentication refresh failed.Refresh failed with a 401 Unauthorized error. Credentials are no longer valid. 

    In the Log Stream (in portal.azure) I see the following message:
    > HTTP Error 401.83 - Unauthorized You do not have permission to view this directory or page.Most likely causes:The authenticated user does not have access to a resource needed to process the request.Things you can try:Create a tracing rule to track failed requests for this HTTP status code. 

    This is my authenticate method, following the Mobile Apps documentation:

    private void authenticate() {
        // Sign in using the Google provider.
        HashMap parameters = new HashMap<>();
        parameters.put("access_type", "offline");
        parameters.put("prompt", "consent");
        mClient.login(MobileServiceAuthenticationProvider.Google, url_scheme_of_your_app, GOOGLE_LOGIN_REQUEST_CODE, parameters); 

    This is my refresh token method:
    private void refreshToken(){mClient.refreshUser(new UserAuthenticationCallback() {
            public void onCompleted(MobileServiceUser user, Exception exception, ServiceFilterResponse response) {
            if (user != null && exception == null) {
            /*refresh succeeded*/
            } else { 
            /*refresh failed*/
            String message = "+"%s authentication refresh failed.Error: %s", "Google",exception.getMessage())";
    } }}); }

    My Azure Service Plan is type: (D1: Shared)

    • Edited by cherryypr Friday, January 10, 2020 3:15 PM
    Friday, January 10, 2020 3:08 PM

All replies