iOS | Android |
---|---|
Source of example app: https://github.com/adamjmcgrath/ReactNativeSimpleAuthExample
yarn add react-native-simple-auth
launchMode
of MainActivity
to singleTask
in AndroidManifest.xml
, create the deep link schemes in Providers Setup)com.reactnativesimpleauth
appId
and 'Bundle ID' in the callback
(note the single /
, you can put anything as the path), eg
{
appId: '123-123abc.apps.googleusercontent.com',
callback: 'com.reactnativesimpleauthexample:/oauth2redirect'
}
com.reactnativesimpleauthexample
) to your AndroidManifest.xml
eg https://github.com/adamjmcgrath/ReactNativeSimpleAuthExample/blob/master/android/app/src/main/AndroidManifest.xml#L28-L33Settings
, click Add Platform
Bundle ID
field, add fb{your App ID}
eg fb1234567890
(You can use the same configuration for Android)appId
and 'Bundle ID' in the callback
(you must put ://authorize
), eg
{
appId: '1234567890',
callback: 'fb1234567890://authorize',
scope: 'user_friends', // you can override the default scope here
fields: ['email', 'first_name', 'last_name'], // you can override the default fields here
}
fb1234567890
) to your AndroidManifest.xml
eg https://github.com/adamjmcgrath/ReactNativeSimpleAuthExample/blob/master/android/app/src/main/AndroidManifest.xml#L28-L33appId
, the 'Consumer Secret' as appSecret
and the Twitter App name
in the callback
, eg
{
appId: 'abc1234567890',
appSecret: 'cba0987654321',
callback: 'testapp://authorize',
}
testapp
) to your AndroidManifest.xml
eg https://github.com/adamjmcgrath/ReactNativeSimpleAuthExample/blob/master/android/app/src/main/AndroidManifest.xml#L28-L33appId
, the 'OAuth Consumer Secret' as appSecret
and any callback
, eg
{
appId: '1234567890abc',
appSecret: '1234567890abc',
callback: 'testapp://authorize',
}
testapp
) to your AndroidManifest.xml
eg https://github.com/adamjmcgrath/ReactNativeSimpleAuthExample/blob/master/android/app/src/main/AndroidManifest.xml#L28-L33{
appId: '123456789',
callback: 'testapp://authorize',
}
Create a configuration object for each of the providers you want to authorize with (required keys are in parenthesis):
appId
, callback
)appId
, callback
)appId
, appSecret
, callback
)appId
, appSecret
, callback
)See secrets.example.js.
import { google, facebook, twitter, tumblr } from 'react-native-simple-auth';
google({
appId: '123-123abc.apps.googleusercontent.com',
callback: 'com.reactnativesimpleauthexample:/oauth2redirect',
}).then((info) => {
// info.user - user details from the provider
// info.credentials - tokens from the provider
}).catch((error) => {
// error.code
// error.description
});
react-native-simple-auth is released under the MIT license.