Trying to acquireTokenSilentAsync from android app

Viewed 377

I'm currently using

implementation 'com.microsoft.identity.client:msal:1.4.0'

to connect to the app via azure , my acquireToken() works fine and I get the user in response ( I save it in the SharedPrefs)

After that (next login) I'm trying to do acquireTokenSilentAsync like so :

      SharedPreferences pref = getSharedPreferences();

      Gson gson = new Gson();
      String json = pref.getString("IAccount", "");


      if(!json.isEmpty()){
          Account account = gson.fromJson(json, Account.class);
          AcquireTokenSilentParameters parameters = new AcquireTokenSilentParameters.Builder()
              .withScopes(Arrays.asList(scopes))
              .forAccount(account)
              .fromAuthority(getAuthority())
              .withCallback(getSilentAuthInteractiveCallback())
              .build();
          application.acquireTokenSilentAsync(parameters);
      }

And get to the onError callback with the exception of :

>  E/onError: exception : com.microsoft.identity.client.Account cannot be cast to com.microsoft.identity.client.MultiTenantAccount

Any ideas what's missing ?

Much Appreciated.

1 Answers
Related