MaikuB / flutter_appauth

A Flutter wrapper for AppAuth iOS and Android SDKs
269 stars 239 forks source link

Failed to authorize: [error: null, description: Invalid ID Token] #369

Closed zachary22321 closed 1 year ago

zachary22321 commented 1 year ago

Periodically when I login I get this error: Issued at time is more than 10 minutes before or after the current time

I'm using Android Emulator.

What's the best way to handle this error gracefully? Do I need to delete the token somehow?

 FlutterAppAuth _appauth = FlutterAppAuth();
  AuthorizationTokenResponse? result;
  try {
    result = await _appauth.authorizeAndExchangeCode(
      AuthorizationTokenRequest("9c5b0d6d-f716-408b-8fca-53f17674f14a",
          "money.saveextra.app://auth",
          discoveryUrl:
          "https://saveextramoneydevelopment.b2clogin.com/saveextramoneydevelopment.onmicrosoft.com/v2.0/.well-known/openid-configuration?p=B2C_1_mobilesignup",
          scopes: [
            'openid',
          ]),

    );
  }
  catch(e){
    var  z =5;
    throw e;
  }

  var token = result?.idToken;

  ref.read(tokenProvider.notifier).state=token;
  ServiceConfig.setToken(token!);

  NavigationService.instance.navigateToReplacement("loading");
linjmeyer commented 1 year ago

@zachary22321 did you figure this out? I'm having the same issue on a project and I'm not sure why

linjmeyer commented 1 year ago

ah this is really dumb, the Android Emulator's time was out of sync. Not sure how that happens, but I restarted it and it caught back up to real time.