Git Product home page Git Product logo

react-native-oauth's Introduction

react-native-oauth

The react-native-oauth library provides an interface to OAuth 1.0 and OAuth 2.0 providers with support for the following providers for React Native apps:

  • Twitter
  • Facebook
  • Google
  • Github
  • Slack

TL;DR;

This library cuts out the muck of dealing with the OAuth 1.0 and OAuth 2.0 protocols in react-native apps. The API is incredibly simple and straight-forward and is intended on getting you up and running quickly with OAuth providers (such as Facebook, Github, Twitter, etc).

import OAuthManager from 'react-native-oauth';

const manager = new OAuthManager('firestackexample')
manager.configure({
  twitter: {
    consumer_key: 'SOME_CONSUMER_KEY',
    consumer_secret: 'SOME_CONSUMER_SECRET'
  },
  google: {
    callback_url: `io.fullstack.FirestackExample:/oauth2redirect`,
    client_id: 'YOUR_CLIENT_ID',
    client_secret: 'YOUR_SECRET'
  }
});

// ...
manager.authorize('google', {scopes: 'profile email'})
.then(resp => console.log('Your users ID'))
.catch(err => console.log('There was an error'));

Help

Due to other time contraints, I cannot continue to work on react-native-oauth for the time it deserves. If you're interested in supporting this library, please help! It's a widely used library and I'd love to continue supporting it. Looking for maintainers!

Features

  • Isolates the OAuth experience to a few simple methods.
  • Atomatically stores the tokens for later retrieval
  • Works with many providers and simple to add new providers
  • Works on both Android and iOS
  • Makes calling API methods a snap
  • Integrates seamlessly with Firestack (but can be used without it)

Installation

Install react-native-oauth in the usual manner using npm:

npm install --save react-native-oauth

As we are integrating with react-native, we have a little more setup to integrating with our apps.

iOS setup

Important: This will not work if you do not complete all the steps:

  • Link the RCTLinkingManager project
  • Update your AppDelegate.h file
  • Add KeychainSharing in your app
  • Link the react-native-oauth project with your application (react-native link)
  • Register a URL type of your application (Info tab -- see below)

RCTLinkingManager

Since react-native-oauth depends upon the RCTLinkingManager (from react-native core), we'll need to make sure we link this in our app.

In your app, add the following line to your HEADER SEARCH PATHS:

$(SRCROOT)/../node_modules/react-native-oauth/ios/OAuthManager
$(SRCROOT)/../node_modules/react-native/Libraries/LinkingIOS

Next, navigate to the neighboring "Build Phases" section of project settings, find the "Link Binary with Library" drop down, expand it, and click the "+" to add libOAuthManager.a to the list.

Make sure to Update your AppDelegate.m as below, otherwise it will not work.

Automatically with rnpm

To automatically link our react-native-oauth client to our application, use the rnpm tool. rnpm is a React Native package manager which can help to automate the process of linking package environments.

react-native link react-native-oauth

Note: due to some restrictions on iOS, this module requires you to install cocoapods. The process has been semi-automated through using the above react-native link command.

Once you have linked this library, run the following command in the root directory:

(cd ios && pod install)

Open in xcode the created .xcworkspace in the ios/ directory (NOT THE .xproj file) when it's complete.

When working on iOS 10, we'll need to enable Keychain Sharing Entitlement in Capabilities of the build target of io.fullstack.oauth.AUTH_MANAGER.

Handle deep linking loading

Required step

We'll need to handle app loading from a url with our app in order to handle authentication from other providers. That is, we'll need to make sure our app knows about the credentials we're authenticating our users against when the app loads after a provider is authenticated against.

iOS setup

We need to add a callback method in our ios/AppDelegate.m file and then call our OAuthManager helper method. Let's load the ios/AppDelegate.m file and add the following all the way at the bottom (but before the @end):

// Add the import at the top:
#import "OAuthManager.h"
// ...
@implementation AppDelegate
// ...
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
  return [OAuthManager handleOpenUrl:application
                             openURL:url
                   sourceApplication:sourceApplication
                          annotation:annotation];
}

In addition, we'll need to set up the handlers within the iOS app. Add the following line somewhere in your application:didFinishLaunchingWithOptions: method, like so:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSURL *jsCodeLocation;

  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];

  // other existing setup here

  // ADD THIS LINE SOMEWHERE IN THIS FUNCTION
  [OAuthManager setupOAuthHandler:application];
  // ...

  [self.window makeKeyAndVisible];
  return YES;
}

When our app loads up with a request that is coming back from OAuthManager and matches the url pattern, OAuthManager will take over and handle the rest and storing the credentials for later use.

Adding URL schemes

In order for our app to load through these callbacks, we need to tell our iOS app that we want to load them. In order to do that, we'll have to create some URL schemes to register our app. Some providers require specific schemes (mentioned later).

These URL schemes can be added by navigating to to the info panel of our app in Xcode (see screenshot).

Let's add the appropriate one for our provider. For instance, to set up twitter, add the app name as a URL scheme in the URL scheme box.

Android setup

After we link react-native-oauth to our application, we're ready to go. Android integration is much simpler, thanks to the in-app browser ability for our apps. react-native-oauth handles this for you.

One note, all of the callback urls follow the scheme: http://localhost/[provider_name]. Make sure this is set as a configuration for each provider below (documented in the provider setup sections).

Make sure you add the following to your android/build.gradle file:

maven { url "https://jitpack.io" }

For instance, an example android/build.gradle file would look like this:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
  // ...
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven { url "https://jitpack.io" } // <~ ADD THIS LINE
        maven {
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}

Creating the manager

In our JS, we can create the manager by instantiating a new instance of it using the new method and passing it the name of our app:

const manager = new OAuthManager('firestackexample')

We need to pass the name of our app as the oauth manager uses this to create callback keys. This must match the URL route created in your iOS app. For instance, above we created a URL scheme for Twitter. Pass this as the string in the OAuthManager constructor.

Configuring our providers

Providers, such as Facebook require some custom setup for each one. The following providers have been implemented and we're working on making more (and making it easier to add more, although the code is not impressively complex either, so it should be relatively simple to add more providers).

In order to configure providers, the react-native-oauth library exports the configureProvider() method, which accepts two parameters and returns a promise:

  1. The provider name, such as twitter and facebook
  2. The provider's individual credentials

For instance, this might look like:

const config =  {
  twitter: {
    consumer_key: 'SOME_CONSUMER_KEY',
    consumer_secret: 'SOME_CONSUMER_SECRET'
  },
  facebook: {
    client_id: 'YOUR_CLIENT_ID',
    client_secret: 'YOUR_CLIENT_SECRET'
  }
}
// Create the manager
const manager = new OAuthManager('firestackexample')
// configure the manager
manager.configure(config);

The consumer_key and consumer_secret values are generally provided by the provider development program. In the case of twitter, we can create an app and generate these values through their development dashboard.

Implemented providers

The following list are the providers we've implemented thus far in react-native-oauth and the required keys to pass when configuring the provider:

Twitter (iOS/Android)

To authenticate against twitter, we need to register a Twitter application. Register your twitter application (or create a new one at apps.twitter.com).

Once you have created one, navigate to the application and find the Keys and Access Tokens. Take note of the consumer key and secret:

For the authentication to work properly, you need to set the Callback URL. It doesn't matter what you choose as long as its a valid url.

Twitter's URL scheme needs to be the app name (that we pass into the constructor method). Make sure we have one registered in Xcode as the same name:

Add these values to the authorization configuration to pass to the configure() method as:

const config =  {
  twitter: {
    consumer_key: 'SOME_CONSUMER_KEY',
    consumer_secret: 'SOME_CONSUMER_SECRET'
  }
}

Facebook (iOS/Android)

To add facebook authentication, we'll need to have a Facebook app. To create one (or use an existing one), navigate to developers.facebook.com/.

Find or create an application and find the app id. Take note of this app id. Next, navigate to the Settings panel and find your client_secret.

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}

For instance, my app ID in this example is: 1745641015707619. In the Bundle ID field, I have added fb1745641015707619.

For Android, you will also need to set the redirect url to http://localhost/facebook in the Facebook Login settings.

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:

Back in our application, add the App ID and the secret as:

const config =  {
  facebook: {
    client_id: 'YOUR_APP_ID',
    client_secret: 'YOUR_APP_SECRET'
  }
}

Google (iOS)

To add Google auth to our application, first we'll need to create a google application. Create or use an existing one by heading to the developers.google.com/ page (or the console directly at https://console.developers.google.com).

We need to enable the Identity Toolkit API API. Click on Enable API and add this api to your app. Once it's enabled, we'll need to collect our credentials.

Navigate to the Credentials tab and create a new credential. Create an iOS API credential. Take note of the client_id and the iOS URL scheme. In addition, make sure to set the bundle ID as the bundle id in our application in Xcode:

Take note of the iOS URL Scheme. We'll need to add this as a URL scheme in our app. In the Info panel of our app target (in Xcode), add the URL scheme:

Finally, add the client_id credential as the id from the url page as well as the ios scheme (with any path) in our app configuration:

const config =  {
  google: {
    callback_url: `[IOS SCHEME]:/google`,
    client_id: 'YOUR_CLIENT_ID'
  }
}

Google (Android)

To set up Google on Android, follow the same steps as before, except this time instead of creating an iOS API, create a web api credential. Make sure to add the redirect url at the bottom (it defaults to http://localhost/google):

When creating an Android-specific configuration, create a file called config/development.android.js. React Native will load it instead of the config/development.js file automatically on Android.

Github (iOS/Android)

Adding Github auth to our application is pretty simple as well. We'll need to create a web application on the github apps page, which can be found at https://github.com/settings/developers. Create one, making sure to add two apps (one for iOS and one for Android) with the callback urls as:

Take note of the client_id and client_secret

The iOS URL Scheme is the same as the twitter version, which means we'll just add the app name as a URL scheme (i.e. firestackexample).

Add the client_id and client_secret credentials to your configuration object:

const config =  {
  github: {
    client_id: 'YOUR_CLIENT_ID',
    client_secret: 'YOUR_CLIENT_SECRET'
  }
}

Slack

We'll need to create an app first. Head to the slack developer docs at https://slack.com/developers.

Click on the Getting Started button:

From here, find the create an app link:

Take note of the client_id and the client_secret. We'll place these in our configuration object just like so:

const config =  {
  slack: {
    client_id: 'YOUR_CLIENT_ID',
    client_secret: 'YOUR_CLIENT_SECRET'
  }
}

Lastly, Slack requires us to add a redirect_url.

For iOS: the callback_url pattern is ${app_name}://oauth, so make sure to add your redirect_url where it asks for them before starting to work with the API.

for Android: the callback_url pattern is http://localhost/slack. Be sure to add this to your list of redirect urls.

Authenticating against our providers

We can use the manager in our app using the authorize() method on the manager.

The authorize method takes two arguments (the first one is required):

  • The provider we wish to authenticate against (i.e. twitter, facebook)
  • The list of options on a per-provider basis (optional)

For example:

manager.authorize('twitter')
  .then(resp => console.log(resp))
  .catch(err => console.log(err));

This method returns a promise that is resolved once the authentication has been completed. You'll get access to the authentication keys in the resp object.

The resp object is set as follows:

{
  status: "ok",
  response: {
    authorized: true, (boolean)
    uuid: "UUID", (user UUID)
    credentials: {
      access_token: "access token",
      refresh_token: "refresh token",
      type: 1
    }
  }
}

The second argument accepts an object where we can ask for additional scopes, override default values, etc.

manager.authorize('google', {scopes: 'email,profile'})
  .then(resp => console.log(resp))
  .catch(err => console.log(err));
  • Scopes are a list of scopes comma separated as a string.

Calling a provider's API

We can use OAuthManager to make requests to endpoints from our providers as well. For instance, let's say we want to get a user's time line from twitter. We would make the request to the url https://api.twitter.com/1.1/statuses/user_timeline.json

If our user has been authorized for thi request, we can execute the request using the credentials stored by the OAuthManager.

The makeRequest() method accepts 3 parameters:

  1. The provider we're making a request to
  2. The url (or path) we want to make the request
  3. Any additional options

We can pass a list of options for our request with the last argument. The keys OAuthManager recognizes are:

  1. params - The query parameters
  2. method - The http method to make the request with.

Available HTTP methods:

  • get
  • post
  • put
  • delete
  • head
  • options
  • trace
const userTimelineUrl = 'https://api.twitter.com/1.1/statuses/user_timeline.json';
manager
  .makeRequest('twitter', userTimelineUrl)
  .then(resp => {
    console.log('Data ->', resp.data);
  });

"me" represents the authenticated user, in any call to the Google+ API

const googleUrl = 'https://www.googleapis.com/plus/v1/people/me';
manager
  .makeRequest('google', googleUrl)
    .then(resp => {
      console.log('Data -> ', resp.data);
    });

It's possible to use just the path as well. For instance, making a request with Facebook at the /me endpoint can be:

manager
  .makeRequest('facebook', '/me')
  .then(resp => {
    console.log('Data ->', resp.data);
  });

To add more data to our requests, we can pass a third argument:

manager
  .makeRequest('facebook', '/me', {
    headers: { 'Content-Type': 'application/java' },
    params: { email: '[email protected]' }
  })
  .then(resp => {
    console.log('Data ->', resp.data);
  });

Getting authorized accounts

Since OAuthManager handles storing user accounts, we can query it to see which accounts have already been authorized or not using savedAccounts():

manager.savedAccounts()
  .then(resp => {
    console.log('account list: ', resp.accounts);
  })

deauthorize()

We can deauthorize() our user's from using the provider by calling the deauthorize() method. It accepts a single parameter:

  1. The provider we want to remove from our user credentials.
manager.deauthorize('twitter');

Adding your own providers

To add your own providers you can use the addProvider() method and fill in your provider details:

manager.addProvider({
    'name_of_provider': {
        auth_version: '2.0',
        authorize_url: 'https://provider.dev/oauth',
        access_token_url: 'https://provider.dev/oauth/token',
        callback_url: ({app_name}) => `${app_name}://oauth`,
    }
});

Contributing

This is open-source software and we can make it rock for everyone through contributions.

git clone https://github.com/fullstackreact/react-native-oauth.git
cd react-native-oauth
npm install

TODOS:

react-native-oauth's People

Contributors

alextkd avatar arilitan avatar auser avatar brianjd avatar brunolemos avatar cameron avatar compulsor avatar divyanshunegi avatar frenchbully avatar futuun avatar iamham avatar kottidev avatar madana-i avatar mistenkt avatar mribbons avatar rgabs avatar sailingsteve avatar shohey1226 avatar sleepyfanjo avatar stonehippo avatar thebradbain avatar timbielawski avatar tqc avatar vbuch avatar virae avatar youbiak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-oauth's Issues

Slack Support

Hello... I have a question, If I use it for the Slack provider, will it works?

Cocoapods

sigh this module NEVER loads for me. I'm aware its not an oauth issue, but I cannot find an answer to this issue.
I just get Setting up CocoaPods master repo..... never ends.
Honestly this is just too hard to setup. I think its almost easier to just do it manually.

Using Django Oauth Toolkit

How would I go about using this repo to say integrate authentication with an already created Django REST backend that's using Oauth as authentication?

Slack for Android?

Hi, was just wondering if/when slack for android will be supported?
And/or microsoft support?

Thanks.

Build Fail - Framework not found DCTAuth

I have followed the steps in the README.md up to and including the Handle Deep Linking > Adding URL Schemes.

Upon running the build in XCode I get the following build error:

ld: warning: directory not found for option '-F/Users/<myuser>/Library/Developer/Xcode/DerivedData/MyProject-dbvhqacaurmqvphbjpokfiwipcsy/Build/Products/Debug-iphonesimulator/DCTAuth'
ld: framework not found DCTAuth
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Edit: Running Xcode 7.3.1, React Native v0.37.0, CocoaPods v1.1.1 on Mac OSX 10.11.5

Any ideas on how to resolve?

"libOAuthManager.a" Not found In "Build Phases" section of project settings

After added $(SRCROOT)/../node_modules/react-native-oauth/ios/OAuthManager, according to your suggestion "Next, navigate to the neighboring "Build Phases" section of project settings, find the "Link Binary with Library" drop down, expand it, and click the "+" to add libOAuthManager.a to the list."

Error on get > Cannot be cast to java.util.Map

I am trying to retrieve some user data but unfortunately I am getting error.

I am able to authenticate and get a user token but not make a request. So what am I missing please?

Thank you.

manager
	.makeRequest('google', 'https://www.googleapis.com/oauth2/v1/userinfo')
	.then(resp => {
		console.log('Data ->', resp.data);
	})
	.catch(err => console.log(err));

screen shot 2016-12-12 at 5 35 38 pm

Error when calling manager.savedAccounts

Hi, I have everything up and running, and I'm trying to access the saved account after returning from the auth flow.

Any idea why I am seeing the error below? (myappname is actually set to the value in url schemes as directed in the readme).

ExceptionsManager.js:71 Exception '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]' was thrown while invoking getSavedAccounts on target OAuthManager with params (
        {
        "app_name" = myappname;
    },
    11
)

Thanks.

OAuthManager build error

Hi,

I don't know how to fix this.
I have done all your install procedure and I have this error :

CompileC /Users/ericbrulatout/WebstormProjects/dbot/ios/build/Build/Intermediates/OAuthManager.build/Debug-iphonesimulator/OAuthManager.build/Objects-normal/x86_64/OAuthManager-9417F9659D89048A.o OAuthManager/OAuthManager.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
    cd /Users/ericbrulatout/WebstormProjects/dbot/node_modules/react-native-oauth/ios
    export LANG=en_US.US-ASCII
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch x86_64 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -fmodules-cache-path=/Users/ericbrulatout/WebstormProjects/dbot/ios/build/ModuleCache -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/Users/ericbrulatout/WebstormProjects/dbot/ios/build/ModuleCache/Session.modulevalidation -fmodules-validate-once-per-build-session -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wunreachable-code -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DDEBUG=1 -DOBJC_OLD_DISPATCH_PROTOTYPES=0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.2.sdk -fasm-blocks -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -mios-simulator-version-min=8.0 -g -Wno-sign-conversion -Wno-infinite-recursion -fobjc-abi-version=2 -fobjc-legacy-dispatch -iquote /Users/ericbrulatout/WebstormProjects/dbot/ios/build/Build/Intermediates/OAuthManager.build/Debug-iphonesimulator/OAuthManager.build/OAuthManager-generated-files.hmap -I/Users/ericbrulatout/WebstormProjects/dbot/ios/build/Build/Intermediates/OAuthManager.build/Debug-iphonesimulator/OAuthManager.build/OAuthManager-own-target-headers.hmap -I/Users/ericbrulatout/WebstormProjects/dbot/ios/build/Build/Intermediates/OAuthManager.build/Debug-iphonesimulator/OAuthManager.build/OAuthManager-all-non-framework-target-headers.hmap -ivfsoverlay /Users/ericbrulatout/WebstormProjects/dbot/ios/build/Build/Intermediates/OAuthManager.build/all-product-headers.yaml -iquote /Users/ericbrulatout/WebstormProjects/dbot/ios/build/Build/Intermediates/OAuthManager.build/Debug-iphonesimulator/OAuthManager.build/OAuthManager-project-headers.hmap -I/Users/ericbrulatout/WebstormProjects/dbot/ios/build/Build/Products/Debug-iphonesimulator/include -I/Users/ericbrulatout/WebstormProjects/dbot/node_modules/react-native-oauth/ios/../../node_modules/react-native/React -I../../react-native/React -I../../react-native/React/Base -I../../react-native/React/CSSLayout -I../../react-native/React/Executors -I../../react-native/React/Modules -I../../react-native/React/Profiler -I../../react-native/React/Views -I../../React -I../../React/dist -I../../React/lib -I/Users/ericbrulatout/WebstormProjects/dbot/node_modules/react-native-oauth/ios/../../react-native/Libraries/LinkingIOS -I/Users/ericbrulatout/WebstormProjects/dbot/node_modules/react-native-oauth/ios/../../../ios/Pods/DCTAuth/DCTAuth -I/Users/ericbrulatout/WebstormProjects/dbot/ios/build/Build/Intermediates/OAuthManager.build/Debug-iphonesimulator/OAuthManager.build/DerivedSources/x86_64 -I/Users/ericbrulatout/WebstormProjects/dbot/ios/build/Build/Intermediates/OAuthManager.build/Debug-iphonesimulator/OAuthManager.build/DerivedSources -F/Users/ericbrulatout/WebstormProjects/dbot/ios/build/Build/Products/Debug-iphonesimulator -MMD -MT dependencies -MF /Users/ericbrulatout/WebstormProjects/dbot/ios/build/Build/Intermediates/OAuthManager.build/Debug-iphonesimulator/OAuthManager.build/Objects-normal/x86_64/OAuthManager-9417F9659D89048A.d --serialize-diagnostics /Users/ericbrulatout/WebstormProjects/dbot/ios/build/Build/Intermediates/OAuthManager.build/Debug-iphonesimulator/OAuthManager.build/Objects-normal/x86_64/OAuthManager-9417F9659D89048A.dia -c /Users/ericbrulatout/WebstormProjects/dbot/node_modules/react-native-oauth/ios/OAuthManager/OAuthManager.m -o /Users/ericbrulatout/WebstormProjects/dbot/ios/build/Build/Intermediates/OAuthManager.build/Debug-iphonesimulator/OAuthManager.build/Objects-normal/x86_64/OAuthManager-9417F9659D89048A.o
/Users/ericbrulatout/WebstormProjects/dbot/node_modules/react-native-oauth/ios/OAuthManager/OAuthManager.m:47:15: warning: incompatible pointer to integer conversion assigning to 'dispatch_once_t' (aka 'long') from 'void *' [-Wint-conversion]
    onceToken = nil;
              ^ ~~~
/Users/ericbrulatout/WebstormProjects/dbot/node_modules/react-native-oauth/ios/OAuthManager/OAuthManager.m:339:13: error: no visible @interface for 'OAuthClient' declares the selector 'authorizeWithUrl:url:cfg:store:onSuccess:onError:'
    [client authorizeWithUrl:providerName
     ~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning and 1 error generated.

Have you any idea ?

Regards,

client_secret in code

Hi Ari,

i am new to the oAuth topic and it's nice that you created that lib. one thing i was wondering about is that i have to put the client_secret in the code that runs on the device.
in a lot of articles and videos on the authorization code grant flow, they said that the client_secret should stay on the server.

do i miss something?

best
tizian

using response with Firebase

hey Ari - I've got to point where both Google/Facebook auth is returning me good response payloads (per your documentation).

what im struggling with now is how can i use that payload, to then make a login request to Firebase ?

ie the payload i mention above looks like this:

{
  status: "ok",
  response: {
    authorized: true, (boolean)
    uuid: "UUID", (user UUID)
    credentials: {
      access_token: "access token", 
      refresh_token: "refresh token",
      type: 1
    }
  }
}

Xcode 8 and Swift 3

The xcode prompts that the library requires converting to swift 3, I tried converting but to no avail the code still crashes when running.

Build Failed with Linking Error

Hi,
I have installed the pods everything looks good as you instructions, but i get an error i can not fix:
Undefined symbols for architecture x86_64:
"OBJC_CLASS$_OAuthManager", referenced from:
objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

i tried to link several times with rnpm. this is does not

215 Bad Authentication data

Hi, I'm getting "Bad authentication data" error from twitter. Here is my code:

componentWillMount(){
    const home_timeline = 'https://api.twitter.com/1.1/statuses/home_timeline.json';

    manager.authorize('twitter')
    .then(resp => {
      if(resp.response.authorized){
        console.log(resp);
        manager.makeRequest('twitter', home_timeline)
        .then(resp => {
            console.log('Data ->', resp.data);
          });
      }
    })
    .catch(err => console.log(err));
  }

here is my logs:

screen shot 2016-12-06 at 19 39 20

manage.authorize promise is not resolved or rejected

I followed the readme except for when I enabled Keychain Sharing Entitlement in Capabilities I got an error icon next to "Add the Keychain Sharing feature to your App ID" and a message under it saying "Failed to create provisioning profile". Anyway, I was (possibly incorrectly) hoping I could ignore it and see if I could get further into my prototype. I got the rest of the setup done but when my code executes manager.authorize, the resulting promise never gets resolved or rejected. I don't get any kind of error in the debugging console and I don't see requests go to Twitter in the network tab.

My code looks like this:

const manager = new OAuthManager('peoplewatch');
    manager.configure(config);
    manager.authorize('twitter')
      .then((response) => {
        console.log(response);
      })
      .catch((err) => {
        console.log(err);
      });

I tried debugging deeper into the authorize code but it got to where it queues up the call to the native code and lost me after that. Could this be a bug or am I missing something? Thanks!

cannot read property 'configureProvider' of undefined

Hi, as I made reference to here #14
I'm having an issue with the oath on Android. Do I need to configure the manager differently based on platform? At present my code looks like this

const manager = new OAuthManager('MyAPp');
const config = {
  facebook: {
    client_id: 'MY_CLIENT_ID',
    client_secret: 'MY_CLIENT_SECRET',
  },
};
manager.configure(config);

It works amazingly (Thanks @auser !!) on ios, but in android everything about the manager is then coming up as undefined. I removed all my promises handling etc to just strip it back to console logging the manager variable but I was getting 'cannot read property 'configureProvider' of undefined and it wouldn't go any further.

Is this a bug or is this just user error? I (think) I;ve read the docs quite extensively and everything seems as it's supposed to be? Cheers

App crash on vanilla install - `LICreateIconForImage passed NULL CGImageRef image`

Environment

react-native-cli version: 1.0.0
react-native version: 0.31.0
OS: Mac OSX, El Capitan 10.11.6
XCode Version: 7.3.1

Issue/Repro

  1. Create a new React Native project
  2. npm install --save react-native-oauth
  3. rnpm link (per README instructions), or react-native link (it's in react-native core now)
  4. react-native run-ios
  5. Observe that the build appears to run fine, but that the app is not open in simulator
  6. react-native log-ios
  7. Attempt to open the app in simulator
  8. Observe that it immediately crashes to desktop, and the following is dumped to the log window (see step 6)
Aug 14 05:15:42 103-246-99-69 assertiond[27930] <Error>: assertion failed: 15G31 13E230: assertiond + 15801 [3C808658-78EC-3950-A264-79A64E0E463B]: 0x1
Aug 14 05:15:42 103-246-99-69 Unknown[27930] <Error>: 
Aug 14 05:15:42 103-246-99-69 com.apple.CoreSimulator.SimDevice.FF100908-C6A2-4AAA-B129-282E74451653.launchd_sim[27910] (UIKitApplication:org.reactjs.native.example.TestProject[0x54a8][30249]) <Notice>: Service exited due to signal: Trace/BPT trap: 5
Aug 14 05:15:43 103-246-99-69 SpringBoard[27926] <Warning>: LICreateIconForImage passed NULL CGImageRef image
Aug 14 05:15:43 103-246-99-69 SpringBoard[27926] <Warning>: Application 'UIKitApplication:org.reactjs.native.example.TestProject[0x54a8]' crashed.
Aug 14 05:15:43 103-246-99-69 assertiond[27930] <Error>: assertion failed: 15G31 13E230: assertiond + 15801 [3C808658-78EC-3950-A264-79A64E0E463B]: 0x1
Aug 14 05:15:43 103-246-99-69 Unknown[27930] <Error>: 
Aug 14 05:15:43 103-246-99-69 SpringBoard[27926] <Warning>: Reply Error: Connection interrupted

Other Comments

This is all without doing anything further, no references to the library or anything, just a 100% fresh new react native project, with this library added

A cursory google turns up the following: http://stackoverflow.com/questions/28126120/ios-8-app-crash-on-launch-licreateiconforimage-passed-null-cgimageref-image

That includes a link to another question, supposedly solving the first one: http://stackoverflow.com/questions/24333981/ios-app-with-framework-crashed-on-device-dyld-library-not-loaded-xcode-6-beta

Gets a bit beyond me at that point, but I'm thinking if there are additional steps needed, it might be worth documenting them in the README? Apologies if I'm making any noobie mistakes here!

Scopes not working for Google on Android

Hi there,

I'm trying to pass scope to Google as follows:

        manager.authorize('google', {scopes: 'profile email'})
            .then(resp => this.cleanLoginData('google',resp.response))
            .catch(err => console.log('There was an error'))

However, that doesn't seem to provide the email when I try to call manager.makeRequest('google',googleUrl) to https://www.googleapis.com/oauth2/v1/userinfo?alt=json.

The solution was to go into android/src/main/java/io/fullstack/oauth/OAuthManagerProviders.java and change line 101 to String scope = "profile email";

Is this a known issue, or am I doing something wrong? I notice that a lot of the language in the java files refers to "scope" rather than "scopes" (with the "s"), as passed in the above authorize code snippet. Could this be the issue?

Thanks!
Jason

dyld: Library not loaded

This occurs when deploying / debugging in device (works fine in Simulator). If this is the general case, could you update your setup guides?

dyld: Library not loaded: .../Xcode/DerivedData/MyApp-ladsjflkdskjflsdjfkkdl/Build/Products/Debug-iphoneos/libOAuthManager.a
Referenced from: /var/containers/Bundle/Application/.../MyApp.app/App
Reason: image not found

Thank you,

-Ariel

react-native link react-native-oauth fails on Windows

It seems the addition of the prelink and postlink rnpm commands to the json.package prevent Windows users from using this tool. The shell scripts you have written are not windows env compatible and cause rnpm-install to crash. I'll see if I can write a fix for this.

rnpm-install ERR! It seems something went wrong while linking. Error: spawn UNKNOWN
Please file an issue here: https://github.com/facebook/react-native/issues

spawn UNKNOWN

Open external browser rather than InApp browser

Hello. Thanks for create this repo.

My use-case for this repo is consume OAuth for Google. It seems this repo use InApp browser (or embedded browser), which unfortunately Google will deprecate embedded browser OAuth. It will show warning like below.

One of the recommended ways is open new browser for OAuth-ing rather than on embedded browser. So, any idea for it? Thanks ๐Ÿป

AppDelegate.m error: use of undeclared identifier 'OAuthManager'

hi,

After following both the automatic ios setup, and the manual one, I'm seeing this error when attempting to build the project.

Am I supposed to be importing OAuthManager somewhere in AppDelegate.m? Or is it supposed to be a global reference?

/TwitterExample/AppDelegate.m:40:11: error: use of undeclared identifier 'OAuthManager'
  return [OAuthManager handleOpenUrl:application openURL:url sourceApplication:sourceApplication annotation:annotation];
          ^
1 error generated.

** BUILD FAILED **


The following build commands failed:
        CompileC build/Build/Intermediates/TwitterExample.build/Debug-iphonesimulator/TwitterExample.build/Objects-normal/x86_64/AppDelegate.o TwitterExample/AppDelegate.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

java.lang.IllegalArgumentException: Invalid Api secret

I'm creating a facebook app (https://developers.facebook.com)
This is my code:

import OAuthManager from 'react-native-oauth';
const manager = new OAuthManager('test');
manager.configure({
        facebook: {
		client_id: 'xxxx',          //Application ID
		client_Secret: 'xxxxxxxx'   //App secret
	}
});
manager.authorize('facebook')
.then(resp => console.log(resp, 'Your users ID'))
.catch(err => console.log(err, 'There was an error'));

And I have this error:

allErrorMessage: "java.lang.IllegalArgumentException: Invalid Api secret"
errorMessage: "Invalid Api secret"

Any help please ?

Support firebase's redirect_url https://xxx.firebaseapp.com/__/auth/handler

So, I have an Android & iOS app:

  • iOS redirect_uri is http://appname://oauth
  • Android redirect_uri is http://localhost/github

If two redirect_uri are required, I have to to create two oauth applications on GitHub.
Firebase project console only supports 1 clientId and 1 clientId per provider.

How to have a iOS & Android application with only 1 firebase project and 1 oauth application?

I believe a single redirect_url is the answer.
Firebase provides the https://xxx.firebaseapp.com/__/auth/handler.

Is that possible?

Unable to authenticate Twitter; OAuthManager does not print resp object

authenticateTwitterLogin() {
    manager.authorize('twitter', {scopes: 'profile,email'})
      .then(resp => console.log(resp))
      .catch(err => console.log(err));
  }

I am trying to authenticate Twitter with the above code; It opens the twitter login in Safari; upon successful authentication, it asks me to redirect me back to my app SocialStarter and then it does not print/console.log anything.

From what I understand, it should handle the promise and console.log(resp) above, right? It does not do so.

Also if it helps, in my xcode logs I see the following:

called clearPendingAccount: <DCTOAuth1Account: 0x60800032a5a0; type = twitter; identifier = ACFD6CCE-B0A2-4543-B099-EA4EBCB31CDE; credential = (null)>

Any help is much appreciated. Thanks.

Building Failed: Undefined symbols for architecture x86_64:"_OBJC_CLASS_$_OAuthManager"

I've got this error while compiling after following scrupulously the installation process

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_OAuthManager", referenced from:
      objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

restarting or cleaning XCode didn't solve this issue.

Not sure it have to see but React-Native 0.37 removed LinkingIOS class in the profit of a generic Linking one.

My conf:
Xcode v8.1
Mac OS Siera v10.12 (last updates)
React-Native v0.37
Building Settings > Header Search Path:
$(SRCROOT)/../node_modules/react-native/Libraries/LinkingiOS [non-recursive]

My PodFile:

platform :ios, '9.0'
source 'https://github.com/CocoaPods/Specs.git'
pod 'Crashlytics'
pod 'Fabric'
pod 'GoogleMaps'
pod 'DCTAuth', :git => 'https://github.com/danielctull/DCTAuth.git'

Any idea of what is going on here?

manager.authorize(...).then(...) never invoked under iOS

Hi,
I'm using v.2.15 of the library and have following problem in my app. Pressing signInWithTwitter button will redirect to Twitter OAuth page and after successful login i get asked if I want to open this page in "ReactNativeOAuth" (name of my App). After confirming this my application is loaded again but I never get into the then of manager.authorize(...).then(...).

Here is the method that triggers Twitter Login:

...
const manager = new OAuthManager('ReactNativeOAuth')
manager.configure(config)
...
signInWithTwitter() {
    let _this = this

    manager.authorize('twitter', {scopes: 'email'})
            .then(resp => {
              console.log('OAuth ->', resp) // <<<<<< NEVER INVOKED UNDER iOS

              if (resp.authorized) {
                _this.setState({auth: resp})
              }

              return manager.makeRequest('twitter', twitterUserURL + resp.response.uuid)
                .then(resp => {
                  console.log('Twitter ->', resp.data)
                  _this.setState({user: resp.data})
                })
              }
            )
            .catch(err => console.log(err)) // <<<<<< also not invoked under iOS
  }

The weird thing is that it works just fine for Android OS. So I guess it has something to do with the configuration, but I wasn't able to find it.

Also, in the Add KeychainSharing in your app section I have following (notice warning):
screen shot 2017-01-23 at 17 52 43

Any hint is highly appreciated!

Cheers.

RCTBridgeModule.h file not found

Hi, I have a RN project v0.40.0. I've installed Firestack and that recommends I use react-native-oauth. After linking and installing pods, I get the build error, 'RCTBridgeModule.h' file not found in OAuthManager.h.

I have tried replacing,

#import "RCTBridgeModule.h"

with,

#import <React/RCTBridgeModule.h>

Which seems to get rid of the original error but then I get, 'RCTLinkingManager.h' file not found. Doing,

#import <React/RCTLinkingManager.h>

but that results in,

Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_OAuthManager", referenced from:
      objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I also tried leaving the #import "RCTLinkingManager.h" as is and added the following search paths as has been suggested on stackoverflow:

$(SRCROOT)/../node_modules/react-native-oauth/ios/OAuthManager
$(SRCROOT)/../node_modules/react-native/Libraries   (recursive)

The first one fixes another error but I got the same Undefined symbols for architecture i386... error, presumably about the #import "RCTLinkingManager.h"

Here is my cocoapods file, in case it helps you spot something:

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'myproject' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for myproject

  target 'myprojectTests' do
    inherit! :search_paths
    # Pods for testing
  end

end
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
platform :ios, '8.0'

[
  'Firebase',
  'Firebase/Core',
  'Firebase/Auth',
  'Firebase/Storage',
  'Firebase/Database',
  'Firebase/RemoteConfig',
  'Firebase/Messaging'
].each do |lib|
  pod lib
  pod 'DCTAuth', :git => 'https://github.com/danielctull/DCTAuth.git'
end

Note, I'm not very familiar with Cocoapods yet but it kept saying that a podfile already exists and I didn't know if I should elect to overwrite it or not. I ended up merging the firestack one with this oauth one and added in that DCTAuth line above, hope it's right. pod install seemed to work but also gave me a yellow warning in my console,

...target overrides the `HEADER_SEARCH_PATHS` build setting defined in `Pods/Target Support Files/Pods-myproject/Pods-myproject.debug.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

Should I heed this warning?

Thank you

Doesn't support android API 22, version 5.1

My code works for Android API 23, version 6.0 emulator. And doesn't work for ex. android API 22, version 5.1
I get the following
screenshot from 2016-12-16 15 10 17

Could you please add in your documentation which API level is supports your lib.

'import' and 'export' may appear only with 'sourceType: module'

I'm working on implementing Android support, but I'm running into this error when importing OAuthManager on a fresh RN project:

'import' and 'export' may appear only with 'sourceType: module'

Sounds like a Babel issue maybe? It's an entirely fresh project, so it's just using the react-native preset. Do I need to add any extra configuration to get this to work?

OAuthManager is undefined

I can't seem to get the constructor for OAuthManager to work. I started with a vanilla react-native project initiated by "$ react-native init MyProject." Then in installed react-native-oauth, and I tried both rnpm and the manual process for adding react-native-oauth to my Xcode project. But in each case "const authManager = new OAuthManager()" results in an undefined error. The app builds fine in Xcode, and I don't see any issues with the libraries.

I am familiar with React but not React-Native or iOS/Xcode. I assume that the OAuthManager refers to a native library and therefore doesn't need to have an import or require statement at the top of my js file?

Any help would be appreciated.

twitter - is it possible to get the Access Token Secret?

I'm trying to use this to allow my react native app to authenticate against an existing backend. The backend requires both the access token and secret token. However the response from the authorize function only returns the accessToken. Is there any way to get the secret token as well?

twitter crashed

Hi guys,
I got a trouble that when I used method login with twitter: manager.authorize('twitter'), my app is crashed only on iOS. However, it works fine with both of facebook and google.
Beside that, when I set {scopes: 'email'} or {scopes: 'profile'} it returns ok but {scopes: 'email,profile'} return a error invalid_scope. How to get multiple scopes?

Please help me to solve this issue.
Thanks

Not working on android device

I have a hard time debugging why manager.authorize('facebook') call never resolves for me on a device while working on emulator.

login_facebook() {
const config = {
  facebook: {
    client_id: '****',
    client_secret: '****'
  }
}
const manager = new OAuthManager('***dev');
manager.configure(config);

console.log('one');
manager.authorize('facebook')
       .then(data => {
          console.log('two');
          console.log(data);
       })
       .catch(err => {
          console.log('three');
          console.log(err)
       });

}

adb -s device_id logcat | grep -E 'ReactNativeJS|OAuthManager'

I/OAuthManager(28552): configureProvider for facebook
I/ReactNativeJS(28552): one

A small white dialog box appears. Any pointers how to get it working?

I asked also on SO: http://stackoverflow.com/questions/41272204/how-to-fix-oauthmanager-authorize-call-on-android-device

OAuthManager.plist location/format and security implications

A few things relating to #16 and #34.

  1. I'd love to submit a PR updating iOS setup instructions with an example using OAuthManager.plist, instead of hardcoding secrets in JavaScript. (My motivation here is a possibly flawed assumption that this is more secure. [2])

    • Would this file go in ios/<project>/OAuthManager.plist?
    • Any hints on proper formatting? I tried converting
    {
      "facebook": {
        "client_id": "fb123",
        "client_secret": "fb-secret"
      },
      "google": {
        "callback_url": "com.myapp.qa:/google",
        "client_id": "google123"
      }
    }

    to:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
      <key>facebook</key>
      <dict>
        <key>client_id</key>
        <string>fb123</string>
        <key>client_secret</key>
        <string>fb-secret</string>
      </dict>
      <key>google</key>
      <dict>
        <key>callback_url</key>
        <string>com.myapp.qa:/google</string>
        <key>client_id</key>
        <string>google123</string>
      </dict>
    </dict>
    </plist>

    And then removing authManager.configure(authConfig), but no luck so far.

  2. I'm new to native app development, but my understanding is that plist files are actually not in any way secure. ๐Ÿ˜ž And further, even compiled secrets can be reverse engineered. e.g. see http://stackoverflow.com/a/14865695/679702 and also https://www.youtube.com/watch?v=fLnR-zyQWzU (9 minute video). Could you address this?

  3. I'm developing a cross-platform app so will also need to get this working on Android side as well. Would be happy to help implement this same behavior on Android, any suggestions for how to get started?

Thanks!

Cannot build on Android

Error:
node_modules/react-native-oauth/android/src/main/java/io/fullstack/oauth/OAuthManagerFragmentController.java:32: error: cannot find symbol import com.github.scribejava.core.exceptions.OAuthConnectionException; ^ symbol: class OAuthConnectionException location: package com.github.scribejava.core.exceptions /Users/alfredlau/Work/bite/node_modules/react-native-oauth/android/src/main/java/io/fullstack/oauth/OAuthManagerFragmentController.java:281: error: cannot find symbol } catch (OAuthConnectionException ex) {

I'm unable to build my app. Looking into scribejava seems to suggest that exceptions/OAuthConnectionException no longer exists, though I'm not really fluent in Java.

Undefined symbols for architecture arm64 / Does not contain bitcode (iOS)

I'm getting the following error, when I try to build:

Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_OAuthManager", referenced from:
      objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I think I have followed the tutorial and have done everything as it says. Any ideas of how can I solve this??

OAuthManager.h file not found

I did all steps for configuring IOS app, the only problem is this message:
Lexical os Preprocessor Issue
OAuthManager.h file not found

captura de tela 2017-01-17 as 13 49 14

To me seems the file exists in the project, but somehow xcode wont find it.

The OAuth lib is linked too.
captura de tela 2017-01-17 as 13 50 38

What could it be?

Is this supposed to work for Android? Can't even build...

Hello,

I got this working for iOS (with minor difficulty, but it did work), but this does not even build for android:

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring project ':app'.

Could not resolve all dependencies for configuration ':app:_debugCompile'.
Could not find com.github.delight-im:Android-AdvancedWebView:v3.0.0.

Then I added

maven { url "https://jitpack.io" }

to the android/build.gradle, so the package was found, but then I get a compilation error:

node_modules/react-native-oauth/android/src/main/java/io/fullstack/oauth/OAuthManagerModule.java:228: error: cannot find symbol
OAuthRequest request = new OAuthRequest(httpVerb, url.toString(), service);

Any help? The reason I am looking at this package is that I need oAuth support for multiple providers on both iOS and Android.

Thanks...

[iOS] Twitter Authorize Gives Error

I did every step on readme. I get this error

Possible Unhandled Promise Rejection (id: 0):
Cannot read property 'configureProvider' of undefined
TypeError: Cannot read property 'configureProvider' of undefined

Safari cant open page because address is invalid

Any idea why this is showing after we enter credentials into Google ?

the config object for Google looks like this:
google: {
callback_url: 'com.googleusercontent.apps.xxxxxxxxxxxxxx:/google',
client_id: 'xxxxxxxxxmf.apps.googleusercontent.com'
}

image

Different response objects for iOS and Android

Hi,

i've made a simple App that reads user information from twitter once use logs in.
So following call:

manager.authorize('twitter', {scopes: 'email'})
       .then(resp => { console.log('OAuth ->', resp) })
       .catch(err => console.log(err))

gets following responses:

Android:

{
  authorized: true,
  provider:"twitter",
  response: {
    credentials: {
      accessToken: "243289845-8ZpTDfcGALlXujZhavI ...",
      consumerKey: "PI21XdrLJoymr ...",
      type: "Bearer"
    },
    uuid: "243xxxxxx"
  },
  status: "OK"
}

iOS:

{
  provider:"twitter",
  response: {
    authorized: true,
    credentials: {
      access_token: "243289845-8ZpTDfcGALl ...",
      access_token_secret: "VEpo0LrLqkPnl7Y ...",
      type: "Bearer"
    },
    identifier: "7AC33593-9AB2-4CDA-B769-XXXXXXXX"
    uuid: "7AC33593-9AB2-4CDA-B769-XXXXXXXX"
  },
  status: "OK"
}

Notice the different UUIDs, as well as different object structure.

Under Android a call to https://api.twitter.com/1.1/users/show.json?user_id=${uuid} will get user data. But under iOS twitter sends an error object ("user not found"), because UUID is wrong.

Could you please explain this?

Regards.

RCTLinkingManager.h file not found error in OAuthManager.h file

Hi All,

I have followed all the steps to integrate react-native-auth from latest README file. But I am getting linking error(RCTLinkingManager.h file not found error in OAuthManager.h) when importing OAuthManager.h in app delegate at runtime.

I am not able to run the app.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.