aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.43k stars 2.13k forks source link

Auth setSignInUserSession fails to store tokens #3028

Closed cmaronchick closed 5 years ago

cmaronchick commented 5 years ago

Platform: React Native Additional Details: Using Expo to develop

When utilizing the Facebook OAuth flow, calling setSignInUserSession crashes on iOS and causes a non-crashing warning on Android.

To Reproduce Steps to reproduce the behavior:

  1. Sign in a user via Facebook using the /authorize endpoint with the grant_type of code. (using the Expo AuthSession component)
  2. On a successful login and return of the code, call the /token endpoint to retrieve the three tokens.
  3. Create a CognitoUserSession using the three tokens, calling it userSession.
  4. Create a userData object using the user session username and the User Pool object.
  5. Call Auth.createCognitoUser(userData), with let authUser = Auth.createCognitoUser(userData)
  6. Call authUser.setSignInUserSession(userSession).

Expected behavior The user session should be set without issue and Auth.currentAuthenticatedUser() should return the Facebook user.

Actual Behavior On iOS, I receive this error: 'unrecognized selector sent to instance' was thrown while invoking multiSet on target AsyncLocalStorage with params ( ....LastAuthUser

Smartphone (please complete the following information):

Additional context Note that when I use aws-cognito-identity-js and use CognitoUser to create a user and a session, I do not receive an error.

However, when I then call Auth.currentAuthenticatedUser(), it says that no user is logged in. When I reload the app though, the Auth.currentAuthenticatedUser() identifies the user created with the CognitoUser method.

You can turn on the debug mode to provide more info for us by setting window.LOG_LEVEL = 'DEBUG'; in your app.

cmaronchick commented 5 years ago

Ok, I figured this out. When I called Auth.createCognitoUser, it only calls for the username rather than the { Username, Pool } object. When I just provided the username, it all worked as expected.

github-actions[bot] commented 3 years ago

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.