jonsaw / amazon-cognito-identity-dart

Unofficial Amazon Cognito Identity Provider Dart SDK, to easily add user sign-up and sign-in to your mobile and web apps with AWS.
MIT License
204 stars 93 forks source link

Update token #67

Open nicolas-idata opened 4 years ago

nicolas-idata commented 4 years ago

I hope you can help me.

When i generate a token using getIdToken().getJwtToken() it works great, the problem is that i dont know how to deal with refresh. So, eventually the token expires and i get a 401 error.

Can anyone please tell me how can i get a new token ? thanks!

Nick

karan-appgambit commented 4 years ago

Same issue

drakebw commented 4 years ago

Same issue

ni3galave commented 4 years ago

Any support refresh token ?

Karanchamp commented 4 years ago

I found temporary solution I write one function in UserService class

Future<String> getIdToken() async {
    if (_session == null || _session.idToken == null) {
      return null;
    }
    if (!_session.isValid()) {
      print("Refreshing Token...");
      _session = await _cognitoUser.getSession();
    }
    return _session.idToken?.getJwtToken();
  }