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 with refresh tokens (as described in Azure Mobile Apps documentation). The authentication had been working fine for nearly 2 years. For the last 10 days(no changes have been made), my users can no more refresh their auth tokens if the last refresh was made 60 minutes or more ago. The refresh succeeds only if it is called sooner than 1 hour. If the refresh fails, as it frequently does, I must force the user to sign-in again using the Google consent screen in order 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? My Azure Service Plan is type D1: Shared.
The users see this error message in their android device, if the refreshUser() method is called more than 1 hour after the last refresh:
from Why Google authentication token refresh keeps failing recently in Azure Mobile Apps SDK for Android
The users see this error message in their android device, if the refreshUser() method is called more than 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:
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 following the Mobile Apps documentation:private void refreshToken(){mClient.refreshUser(new UserAuthenticationCallback() {
@Override
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())";}}}); }
Authentication settings in Azure portal: from Why Google authentication token refresh keeps failing recently in Azure Mobile Apps SDK for Android
No comments:
Post a Comment