question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RN 0.59 and Cognito federated identity OAuth flow failure

See original GitHub issue

Describe the bug With newest version of react-native the OAuth flow with Cognito Federated Identity fails to sign in the user.

To Reproduce Steps to reproduce the behavior:

  1. In a component wrapped with withOAuth HOC use props.facebookSignIn flow.
  2. The flow will get the code from FB but will fail to get the tokens

Expected behavior Expected the flow to work properly

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • iOS
  • RN 0.59 +
  • aws-amplify 1.1.26
  • aws-amplify-react-native 2.1.10

Smartphone (please complete the following information):

  • iPhone 8plus
  • iOS 12.2
  • RN 0.59 +

Additional context Add any other context about the problem here.

Sample code


const urlOpener = async (url, redirectUrl) => {
  const { type, url: newUrl } = await WebBrowser.openAuthSessionAsync(url, redirectUrl);

  if (type === 'success') {
    await WebBrowser.dismissBrowser();

    if (Platform.OS === 'ios') {
      return Linking.openURL(newUrl);
    }
  }
};

Amplify.configure({
  Auth: {
     oauth: {
      domain: Config.REACT_APP_COGNITO_DOMAIN,
      scope: ['public_profile', 'email'],
      redirectSignIn: `app://signIn`, 
      redirectSignOut: `app://signOut`,
      responseType: 'code',
      urlOpener,
    }
....

<Button onPress={this.props.facebookSignIn} >

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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
loganwedwardscommented, Jun 21, 2019

@mkrn @schellack I can confirm that updating the code with the polyfill and deleting the global results in the same Can't find variable: URLSearchParams. Is there a 3rd party we could use to polyfill with the same api that was previously used?

1reaction
schellackcommented, Jun 8, 2019

@mkrn thanks for posting that workaround. It looks like deleting the URLSearchParams from global causes other issues, even though it does allow auth to start working again.

After implementing your workaround, did you see errors like the one below? If so, how did you work around it?

Can't find variable: URLSearchParams
_initBody
    AppEntry.bundle?platform=android&dev=true&minify=false&hot=false:27145:61
Response
    AppEntry.bundle?platform=android&dev=true&minify=false&hot=false:27309:21
onload
    AppEntry.bundle?platform=android&dev=true&minify=false&hot=false:27364:31
wrapped
    AppEntry.bundle?platform=android&dev=true&minify=false&hot=false:152134:28
dispatchEvent
    AppEntry.bundle?platform=android&dev=true&minify=false&hot=false:29175:31
setReadyState
    AppEntry.bundle?platform=android&dev=true&minify=false&hot=false:28933:31
__didCompleteResponse
    AppEntry.bundle?platform=android&dev=true&minify=false&hot=false:28755:29
emit
    AppEntry.bundle?platform=android&dev=true&minify=false&hot=false:6664:42
__callFunction
    AppEntry.bundle?platform=android&dev=true&minify=false&hot=false:3120:49
<unknown>
    AppEntry.bundle?platform=android&dev=true&minify=false&hot=false:2877:31
__guard
    AppEntry.bundle?platform=android&dev=true&minify=false&hot=false:3074:15
callFunctionReturnFlushedQueue
    AppEntry.bundle?platform=android&dev=true&minify=false&hot=false:2876:21

Read more comments on GitHub >

github_iconTop Results From Across the Web

Identity pools (federated identities) authentication flow
Describes authentication flow in Amazon Cognito. ... GetOpenIdToken returns a new OAuth 2.0 token that is issued by your identity pool.
Read more >
The Complete Guide to User Authentication with the Amplify ...
Amazon Cognito makes this process easy by allowing you to use a single user registry to authenticate users across multiple authentication types.
Read more >
detox - OSCHINA - 中文开源技术交流社区
React Native 0.59.9 发布了。React Native 使开发者只使用 JavaScript 也能编写原生移动应用。 新版本是针对几个 ScrollView 回归的补丁修复版本,更新内容如下: ...
Read more >
Authentication - Social sign-in (OAuth) - JavaScript
OAuth support in Amplify uses Cognito User Pools and supports federation with social providers, which will automatically create a corresponding user in the ......
Read more >
Enable Oauth2 authentication with Cognito
User Pools provide user profiles and authentication tokens for users who sign up directly and for federated users who sign in with social...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found