furaiev / amazon-cognito-identity-dart-2

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
186 stars 114 forks source link

[ASK] Is it possible to getSession with only `refreshToken` value ? #236

Closed derohimat closed 1 year ago

derohimat commented 1 year ago

In my case, I want to integrate a deeplink for login with refreshToken value.

For example https://example.com/login?refreshToken=XYZ

And is it possible to send empty username into CognitoUser class ?

image

      final cognitoUser = CognitoUser('', Config.userPool);
      final cognitoRefreshToken = CognitoRefreshToken(refreshToken);
      final session = await cognitoUser.refreshSession(cognitoRefreshToken);

I have try but get this error. image

furaiev commented 1 year ago

@derohimat I don't think AWS API allows it. At least JS lib doesn't allow - https://github.com/aws-amplify/amplify-js/blob/main/packages/amazon-cognito-identity-js/src/CognitoUser.js#L1386

derohimat commented 1 year ago

Solved, just put empty username and put refresh token here.

Example

          final cognitoUser = CognitoUser('', Config.userPool);
          final cognitoRefreshToken = CognitoRefreshToken(refreshToken);
          final newSession = await cognitoUser.refreshSession(cognitoRefreshToken);