flutter_appauth icon indicating copy to clipboard operation
flutter_appauth copied to clipboard

Failed to authorize: [error: null, description: JSON deserialization error]

Open Decodeuprefo opened this issue 3 years ago • 3 comments

I am trying to authenticate a user using authorizeAndExchangeCode method from FlutterAppAuth 4.0.1. I am getting an exception PlatformException(authorize_and_exchange_code_failed, Failed to authorize: [error: null, description: JSON deserialization error], Value Not of type java.lang.String cannot be converted to JSONObject, null) when I click on login button in my app.

This is what I am doing.

AuthorizationTokenResponse? loginResult = await _appAuth.authorizeAndExchangeCode(AuthorizationTokenRequest(
        AUTH0_CLIENT_ID,
        AUTH0_REDIRECT_URI,
        issuer: AUTH0_ISSUER,
        serviceConfiguration: AuthorizationServiceConfiguration(
               authorizationEndpoint: AUTHORIZATIONENDPOINT,
               tokenEndpoint: TOKENENDPOINT,
               endSessionEndpoint: ENDSESSIONENDPOINT,
               ),
        scopes: AUTH0_SCOPES,
      ));

Is there is anything wrong in this integration, Am I using FlutterAppAuth in correct way? Or anything else I need to do?

Decodeuprefo avatar Jun 27 '22 11:06 Decodeuprefo

An error like this suggests that the response isn't a valid JSON, which in turn implies an incorrect configuration. If so, this is something you would need to look further into. I'm not able to provide more assistance/info on this

MaikuB avatar Jul 07 '22 12:07 MaikuB

If configuration is incorrect then there won't be any log for the login user, Right? But I am getting successful login log in the Auth0 dashboard for all type of login. But getting error when that data needs to be retrieved in the application. So, There is no any error in the configuration.

Decodeuprefo avatar Jul 08 '22 03:07 Decodeuprefo

Not necessarily. For example, you can specify the wrong redirect URL and users can sign in. You're going to need to debug further and double check your config to figure out what's going. The code for the plugin is open-source so that would allow you to debug through the plugin itself

MaikuB avatar Jul 22 '22 23:07 MaikuB