Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTPException On refreshToken #39

Open
thenhawke opened this issue Feb 19, 2020 · 2 comments
Open

HTTPException On refreshToken #39

thenhawke opened this issue Feb 19, 2020 · 2 comments

Comments

@thenhawke
Copy link

I keep getting this exception _TypeError (type '(HttpException) => Null' is not a subtype of type '(dynamic) => dynamic') when I call auth0.auth.refreshToken.

My code to call it is like this:

try {
  var response = await auth0.auth.refreshToken({
    'refreshToken': refreshToken,
  });
  return response;
} catch (e) {
  print("Unable to refresh: ${e.toString()}");
}

The exception is being raised by the await auth0.auth.refreshToken line and isn't being caught by the try ... catch block, it is paused by VSCode. Am I doing something wrong, or is there a bug in the underlying library? Happens on a physical phone and on the emulator.

image

@raafvargas
Copy link

same issue here, but in my case it happen on authorize

final response = await _auth.webAuth.authorize({
  'audience': 'https://${_auth.auth.client.domain}/userinfo',
  'scope': _config.auth0Scopes,
});

@ken-ng-esotec
Copy link

ken-ng-esotec commented Apr 12, 2020

@thenhawke , you need to do two things:

  1. Go into auth0 > APIs > Click on your custom API > Access Settings > Allow Offline Access
  2. Do something like this:
  void _refreshToken() async {
    try {
      var response = await auth.auth.passwordRealm({
        'username': uctrl.text,
        'password': pctrl.text,
        'realm': 'Username-Password-Authentication',
        'scope': 'offline_access'
      });
      Auth0Auth authClient = Auth0Auth(
          auth.auth.clientId, auth.auth.client.baseUrl,
          bearer: response['access_token']);
      var info = await authClient.refreshToken({
        'refreshToken': '${response['refresh_token']}',
      });
      showInfo('Refresh Token', '''
        \ntoken_type: ${info['token_type']}
        \naccesstoken: ${info['access_token']}
        ''');
    } catch (e) {
      print(e);
    }
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants