faisalmaqsood01 / react-native-simple-auth

SimpleAuth iOS wrapper for React Native

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

react-native-simple-auth Build Status

SimpleAuth iOS wrapper for React Native

Screencast

Screencast

Install

  1. npm install react-native-simple-auth
  2. In XCode, in the project navigator right click LibrariesAdd Files to [your project's name]
  3. Go to node_modulesreact-native-simple-auth➜ iOS and add SimpleAuthWrapper.h and SimpleAuthWrapper.m
  4. Go to your project's root directory and add a Podfile similar to https://github.com/adamjmcgrath/react-native-simple-auth/blob/master/Podfile
  5. Install CocoaPods https://guides.cocoapods.org/using/getting-started.html
  6. Run pod install

Usage

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;
});

License

react-native-simple-auth is released under the MIT license.

Thanks

About

SimpleAuth iOS wrapper for React Native

License:MIT License


Languages

Language:JavaScript 59.9%Language:Objective-C 38.7%Language:Ruby 1.4%