react-native-oauth
react-native-oauth copied to clipboard
Facebook doesn't accept OAuth Redirect URI specified by tutorial
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
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.
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.

Then in XTools, setup your scheme

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",
}