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.

Using Federated Login/ Cognito with react-native

See original GitHub issue

** Which Category is your question related to? ** Auth ** What AWS Services are you utilizing? ** Amplify +Cognito User Pools + federated identity + facebook login ** Provide additional details e.g. code snippets **

First of all Great lib thanks!.

I’m failing to get facebook login working using amplify with react-native. I’m not sure exactly how the callback to the native mobile app works. I’m pretty sure my issue lies somewhere in callback configuration. My react native app calls out using to facebook using:

 Auth.federatedSignIn({ provider: "Facebook" })

Facebook requests the permissions then and after the I confirm it calls out to : https://MYAPPBUNDLEID:/authorize

I have set that value to the callback URL in my cognito app client settings to https://MYAPPBUNDLEID:/authorize

So my questions are:

  1. What value should the value for redirectSignIn in aws-exports be when using react-native? (is https://com.bundleid:/authrorize correct?)
  2. What value should I use for callback URLs in cognito’s “App Client Settings” when using working with react-native? (is https://com.bundleid:/authrorize correct?)
  3. Do I need to handle the callback manually with iOS openurl API or do one of the AWS SDKs handle that for us? not clear in the docs?

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
ghostcommented, May 20, 2019

@waltermvp ah, in that case, I do have that setup correctly "/. This is my current scenario: signIn with facebook button -> navigated to facebook auth page -> navigated back into app.

This flow seems correct. The only issue is that I do not have access to the data returned (tokens etc…). The Hub.listen() does not get triggered with this scenario.

2reactions
waltermvpcommented, May 19, 2019

@chriscraiclabs I did. For me the issue was that i was using the incorrect redirectURI. Have you setup your android/ios app to handle the url linking call?

basic hub listening:

    Hub.listen("auth", async ({ payload: { event, data } }) => {
      switch (event) {
        case "signIn": {
          this.props.navigation.navigate("AppRootSwitchNavigator");
          this.setState({ user: data });
          break;
        }
        case "signOut": {
          this.props.navigation.navigate("Auth");
          this.setState({ user: null });
          break;
        }
      }
    });
Read more comments on GitHub >

github_iconTop Results From Across the Web

Authentication - Social sign-in (OAuth) - React Native
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 >
React Native - Integrate AWS Cognito User Pools with Azure ...
This is an example about how to use AWS Cognito Hosted UI with Active Directory Federated Identity provider in React native ...
Read more >
Setting up AWS Cognito and React Native to enable ...
Previously we looked at how to set up Amazon Cognito User Pools to work with federated Single Sign On (SSO). This is important...
Read more >
AWS Amplify + React Native / Authentication FULL SETUP
AWS Amplify supports Amazon Cognito in a variety of ways. First of all, you can create and configure Amazon Cognito services directly from...
Read more >
AWS Cognito Revoke federation login - Stack Overflow
Our React native application is currently using AWS cognito (with amplify) to authenticate our users. This login allow user to use "Sign ...
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