SimpleAuth iOS wrapper for React Native
- Install react native and make sure it works. There are currently two supported approaches for installing React-Native, npm or CocoaPods. Users have found the
npmapproach more stable for this library. npm install react-native-simple-auth- In XCode, in the project navigator right click
Libraries➜Add Files to [your project's name] - Go to
node_modules➜react-native-simple-auth➜ iOS and addSimpleAuthWrapper.handSimpleAuthWrapper.m - Go to your project's root directory and add a Podfile similar to this example.
- You may need to tell the podfile where to find your xcode project by adding the following to the podfile:
xcodeproj './path/to/your/.xcodeproj/project'
- Install CocoaPods https://guides.cocoapods.org/using/getting-started.html
- Run
pod install
If you encounter problems building the project after this, the following install tips may be of help.
Create a configuration object for each of the providers you want to authorize with (required keys are in parenthesis):
- google-web (
client_id,client_secret) - facebook (
app_id) - twitter (
consumer_key,consumer_secret) - instagram (
client_id,redirect_uri) - tumblr (
consumer_key,consumer_secret) - linkedin-web (
client_id,client_secret,redirect_uri)
See secrets.example.js.
Other providers supported by SimpleAuth may work, but haven't been tested.
Create an instance of the SimpleAuthWrapper library:
let simpleAuthClient = require('react-native-simple-auth');Configure the library with a single provider:
simpleAuthClient.configure('twitter', {
consumer_key: 'KEY',
consumer_secret: 'SECRET'
}).then(() => {
// Twitter is configured.
})Or multiple providers:
simpleAuthClient.configure({
twitter: {
consumer_key: 'KEY',
consumer_secret: 'SECRET'
},
facebook: {
app_id: 'ID'
}
}).then(() => {
// Twitter & Facebook are configured.
});Then authorize each provider:
simpleAuthClient.authorize('twitter').then((info) => {
let token = info.token;
let name = info.name;
}).catch((error) => {
let errorCode = error.code;
let errorDescription = error.description;
});react-native-simple-auth is released under the MIT license.
- calebd for the code review and SimpleAuth library
