flutter_appauth icon indicating copy to clipboard operation
flutter_appauth copied to clipboard

Getting discovery_failed?

Open itaishalom opened this issue 4 years ago • 8 comments

Hi, any idea what this means? It happens on android 10, but not always. PlatformException(discovery_failed, Error retrieving discovery document: [error: null, description: Network error], null, null).

The code:

` Future<TokenResponse> reLoginAction(String storedRefreshToken) async {

return await synchronized(() async {

  try {

    final TokenResponse? result = await _appAuth.token(TokenRequest(

      this.clientId,

      REDIRECT_URI,

      issuer:

          'https://${this.domain}/oauth2/***********', //real string

      discoveryUrl: OKTA_DISCOVERY_URL,

      refreshToken: storedRefreshToken,
    ));

    return result!;

  } on Exception catch (e, s) {

    logger.e('error on login', e, s);

  }

  throw Exception("ReSign in issue");

});

}`

itaishalom avatar Oct 16 '21 12:10 itaishalom

If you look at the description of the error it says "Network error" so implies there's an issue getting the discovery document, possibly due to network connectivity issues or other reasons. This is outside of the control of the plugin

MaikuB avatar Oct 19 '21 08:10 MaikuB

Ok, currently investigating this issue with Okta. Thanks.

itaishalom avatar Oct 20 '21 09:10 itaishalom

Have you checked to make sure it's not a connection issue on your end? I've tried this with Okta in the past for testing purposes and didn't run into issues. I recall hearing off others using this plugin with Okta too and didn't see reports of issues like this

MaikuB avatar Oct 20 '21 09:10 MaikuB

Well, the strange thing is that 98% of the times, this code works. 2% of the time it fails (and then I have a fall back that opens the browser just fine for the login).

itaishalom avatar Oct 20 '21 09:10 itaishalom

I'm having the same issue. It had been working correctly until the past week. Now, I noticed these problems in Android. I'm sure it doesn't have anything related to connection problems.

allensalinas avatar Oct 22 '21 15:10 allensalinas

Who is the issuer?

itaishalom avatar Oct 22 '21 20:10 itaishalom

I'm also getting the same error. The full error is

PlatformException (PlatformException(discovery_failed, Error retrieving discovery document: [error: null, description: Network error], null, null))

plantshopping avatar Dec 29 '21 02:12 plantshopping

This error is outside of the plugin's control. It would be when the native SDKs detect a network error as it fails to hit the discovery endpoint due to either a connection issue or wrong information being provided. You could try to explicitly specify the endpoints but if it's connection issue then chances are it won't help

MaikuB avatar Jan 05 '22 10:01 MaikuB