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

How to invalidate token programmatically #12

Closed mikes222 closed 6 years ago

mikes222 commented 6 years ago

if the cognito session (namely the accesstoken/idtoken) is not valid (_session.isValid()) I get a new token in exchange for the refreshtoken by calling _cognitoUser.getSession(). This is working.

Once in a while I would like to invalidate the session and retrieve a new accesstoken/idtoken in exchange for the refreshtoken.

Something like _session.invalidateToken()

so that the next attempt to retrieve the token results in refreshing the token from cognito-server: Future<String> retrieveToken() async { if (_session.isValid()) return _session.getIdToken().getJwtToken(); this._session = await _cognitoUser.getSession(); return _session.getIdToken().getJwtToken(); }

Is this possible somehow already? If not can this implemented into the library?

jonsaw commented 6 years ago

Will look into it @mikes222

jonsaw commented 6 years ago

Is this similar to Use Case 32 in amazon-cognito-identity-js?

mikes222 commented 6 years ago

Unfortunately not. #uc32 describes the behavior if the refresh token is expired.

In my usecase none of the tokens are expired. I just want to get a new id token from cognito server without forcing the user to logon manually by entering its credentials.

What i want to do is forcing your library to refresh the token. Something like session.invalidatetoken() so that the next call to session.isvalid() returns false and cognitouser.getsession() retrieves new tokens from cognito server by using the refresh token.

On June 5, 2018 11:22:21 AM GMT+02:00, Jon Saw notifications@github.com wrote:

Is this similar to Use Case 32 in amazon-cognito-identity-js?

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/jonsaw/amazon-cognito-identity-dart/issues/12#issuecomment-394642137

-- Sent from my Android device with K-9 Mail. Please excuse my brevity.

jonsaw commented 6 years ago

Thanks @mikes222 will take a look at the PR!

jonsaw commented 6 years ago

Deployed to v0.0.17