Home

Awesome

react-native-simple-auth Build Status

OAuth login for React Native

Screencast

iOSAndroid
ScreencastScreencast

Source of example app: https://github.com/adamjmcgrath/ReactNativeSimpleAuthExample

Install

Providers Setup

Google

{
  appId: '123-123abc.apps.googleusercontent.com',
  callback: 'com.reactnativesimpleauthexample:/oauth2redirect'
}

Facebook

{
  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
}

Twitter

{
  appId: 'abc1234567890',
  appSecret: 'cba0987654321',
  callback: 'testapp://authorize',
}

Tumblr

{
  appId: '1234567890abc',
  appSecret: '1234567890abc',
  callback: 'testapp://authorize',
}

Untappd

{
  appId: '123456789',
  callback: 'testapp://authorize',
}

Usage

Create a configuration object for each of the providers you want to authorize with (required keys are in parenthesis):

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

License

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