react-native-oauth icon indicating copy to clipboard operation
react-native-oauth copied to clipboard

Facebook doesn't accept OAuth Redirect URI specified by tutorial

Open tomprogers opened this issue 8 years ago • 1 comments

Per the instructions in the readme, I tried to register a new OAuth Redirect URI via Facebook's dev site. Here's the relevant part:

Before we leave the Facebook settings, we need to tell Facebook we have a new redirect url to register. Navigate to the bottom of the page and add the following into the bundle ID field:

fb{YOUR_APP_ID}

We'll need to create a new URL scheme for Facebook and (this is a weird bug on the Facebook side) the facebook redirect URL scheme must be the first one in the list. The URL scheme needs to be the same id as the Bundle ID copied from above.

Facebook won't accept the new redirect URL scheme. It says:

[0] should represent a valid URL

screen shot 2017-02-16 at 8 06 37 pm

I know this isn't exactly a bug in react-native-oauth, but it certainly suggests the instructions in this repo are no longer accurate, which seems like a valid doc issue.

tomprogers avatar Feb 17 '17 02:02 tomprogers

I got it working.

For iOS don't bother trying to add a URL at all on Facebook Login/Settings/"Valid OAuth redirect URIs" field. That field will not accept a iOS scheme, only http:// or https:// schemes.

Instead go to https://developers.facebook.com/apps/<your id>/settings/

If you do not have an "iOS" platform, click that "+ Add Platform" button at the bottom, and add iOS. For both the "Bundle ID" and "URL Scheme Suffix (Optional)" add the fb{YOUR_APP_ID} as suggested.

screen shot 2017-10-11 at 2 59 39 pm

Then in XTools, setup your scheme

screen shot 2017-10-11 at 3 00 57 pm

and in React,

    oauthManager.configure({
      twitter: {
        consumer_key: WebAppConfig.SOCIAL_AUTH_TWITTER_KEY,
        consumer_secret: WebAppConfig.SOCIAL_AUTH_TWITTER_SECRET,
        callback_url: (Platform.OS === 'ios') ? "wevotetwitterscheme://twitter_sign_in" : "http://localhost/twitter",
      },
      facebook: {
        client_id:  WebAppConfig.SOCIAL_AUTH_FACEBOOK_KEY,
        client_secret:  WebAppConfig.SOCIAL_AUTH_FACEBOOK_SECRET,
        callback_url: "fb1097389196952441://authorize",
  }

SailingSteve avatar Oct 11 '17 18:10 SailingSteve