GithubHelp home page GithubHelp logo

react-native-google-signin / google-signin Goto Github PK

View Code? Open in Web Editor NEW
3.1K 3.1K 878.0 22.98 MB

Google Sign-in for your React Native applications

Home Page: https://react-native-google-signin.github.io/

License: MIT License

Objective-C 20.57% JavaScript 5.14% Java 41.45% Ruby 2.99% TypeScript 29.33% Swift 0.51%
googleauth googlesignin hacktoberfest oauth2 react-native

google-signin's Introduction

React Native Google Sign In

NPM Version

❤️❤️ New documentation site available! ❤️❤️

Features

  • Support all 3 types of authentication methods (standard, with server-side validation or with offline access (aka server-side access))
  • Promise-based API consistent between Android and iOS
  • Typings for TypeScript and Flow
  • Mock of the native module for testing with Jest
  • Native sign in buttons

Project setup and initialization

Please follow the "Installation" and "Setting up" guides at react-native-google-signin.github.io.

Then, if you're a sponsor (as explained here), you can continue using the guides on the dedicated documentation site. If not, please use this readme file.

Public API

1. GoogleSignin

This exposes the legacy Google Sign-In for Android and Google Sign-In for iOS SDKs.

import {
  GoogleSignin,
  GoogleSigninButton,
  statusCodes,
} from '@react-native-google-signin/google-signin';

configure(options): void

It is mandatory to call this method before attempting to call signIn() and signInSilently(). This method is sync meaning you can call signIn / signInSilently right after it. In typical scenarios, configure needs to be called only once, after your app starts. In the native layer, this is a synchronous call. All parameters are optional.

Example usage with default options: you get user email and basic profile info.

import { GoogleSignin } from '@react-native-google-signin/google-signin';

GoogleSignin.configure();

An example with all options enumerated:

GoogleSignin.configure({
  scopes: ['https://www.googleapis.com/auth/drive.readonly'], // what API you want to access on behalf of the user, default is email and profile
  webClientId: '<FROM DEVELOPER CONSOLE>', // client ID of type WEB for your server. Required to get the idToken on the user object, and for offline access.
  offlineAccess: true, // if you want to access Google API on behalf of the user FROM YOUR SERVER
  hostedDomain: '', // specifies a hosted domain restriction
  forceCodeForRefreshToken: true, // [Android] related to `serverAuthCode`, read the docs link below *.
  accountName: '', // [Android] specifies an account name on the device that should be used
  iosClientId: '<FROM DEVELOPER CONSOLE>', // [iOS] if you want to specify the client ID of type iOS (otherwise, it is taken from GoogleService-Info.plist)
  googleServicePlistPath: '', // [iOS] if you renamed your GoogleService-Info file, new name here, e.g. GoogleService-Info-Staging
  openIdRealm: '', // [iOS] The OpenID2 realm of the home web server. This allows Google to include the user's OpenID Identifier in the OpenID Connect ID token.
  profileImageSize: 120, // [iOS] The desired height (and width) of the profile image. Defaults to 120px
});

* forceCodeForRefreshToken docs

signIn(options: { loginHint?: string })

Prompts a modal to let the user sign in into your application. Resolved promise returns an userInfo object. Rejects with error otherwise.

Options: an object which contains a single key:

loginHint: [iOS-only] The user's ID, or email address, to be prefilled in the authentication UI if possible. See docs here

// import statusCodes along with GoogleSignin
import { GoogleSignin, statusCodes } from '@react-native-google-signin/google-signin';

// Somewhere in your code
signIn = async () => {
  try {
    await GoogleSignin.hasPlayServices();
    const userInfo = await GoogleSignin.signIn();
    setState({ userInfo });
  } catch (error) {
    if (error.code === statusCodes.SIGN_IN_CANCELLED) {
      // user cancelled the login flow
    } else if (error.code === statusCodes.IN_PROGRESS) {
      // operation (e.g. sign in) is in progress already
    } else if (error.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
      // play services not available or outdated
    } else {
      // some other error happened
    }
  }
};

addScopes(options: { scopes: Array<string> })

This method resolves with userInfo object or with null if no user is currently logged in.

You may not need this call: you can supply required scopes to the configure call. However, if you want to gain access to more scopes later, use this call.

Example:

const user = await GoogleSignin.addScopes({
  scopes: ['https://www.googleapis.com/auth/user.gender.read'],
});

signInSilently()

May be called e.g. after of your main component mounts. This method returns a Promise that resolves with the current user and rejects with an error otherwise.

To see how to handle errors read signIn() method

getCurrentUserInfo = async () => {
  try {
    const userInfo = await GoogleSignin.signInSilently();
    setState({ userInfo });
  } catch (error) {
    if (error.code === statusCodes.SIGN_IN_REQUIRED) {
      // user has not signed in yet
    } else {
      // some other error
    }
  }
};

isSignedIn()

This method may be used to find out whether some user previously signed in. It returns a promise which resolves with a boolean value (it never rejects). In the native layer, this is a synchronous call and will resolve even when the device is offline.

Note that isSignedIn() can return true but getCurrentUser() can return null in which case you can call signInSilently() to recover the user. However, it may happen that calling signInSilently() rejects with an error (e.g. due to a network issue).

isSignedIn = async () => {
  const isSignedIn = await GoogleSignin.isSignedIn();
  setState({ isLoginScreenPresented: !isSignedIn });
};

getCurrentUser()

This method resolves with null or userInfo object of the currently signed-in user. The call never rejects and in the native layer, this is a synchronous call.

getCurrentUser = async () => {
  const currentUser = await GoogleSignin.getCurrentUser();
  setState({ currentUser });
};

clearCachedAccessToken(accessTokenString)

This method only has an effect on Android. You may run into a 401 Unauthorized error when a token is invalid. Call this method to remove the token from local cache and then call getTokens() to get fresh tokens. Calling this method on iOS does nothing and always resolves. This is because on iOS, getTokens() always returns valid tokens, refreshing them first if they have expired or are about to expire (see docs).

getTokens()

Resolves with an object containing { idToken: string, accessToken: string, } or rejects with an error. Note that using accessToken for identity assertion on your backend server is discouraged.

signOut()

Signs out the current user.

signOut = async () => {
  try {
    await GoogleSignin.signOut();
    setState({ user: null }); // Remember to remove the user from your app's state as well
  } catch (error) {
    console.error(error);
  }
};

revokeAccess()

Removes your application from the user authorized applications. Read more about it here and here.

revokeAccess = async () => {
  try {
    await GoogleSignin.revokeAccess();
    // Google Account disconnected from your app.
    // Perform clean-up actions, such as deleting data associated with the disconnected account.
  } catch (error) {
    console.error(error);
  }
};

hasPlayServices(options)

Checks if device has Google Play Services installed. Always resolves to true on iOS.

Presence of up-to-date Google Play Services is required to show the sign in modal, but it is not required to perform calls to configure and signInSilently. Therefore, we recommend to call hasPlayServices directly before signIn.

try {
  await GoogleSignin.hasPlayServices({ showPlayServicesUpdateDialog: true });
  // google services are available
} catch (err) {
  console.error('play services are not available');
}

hasPlayServices accepts one parameter, an object which contains a single key: showPlayServicesUpdateDialog (defaults to true). When showPlayServicesUpdateDialog is set to true the library will prompt the user to take action to solve the issue, as seen in the figure below.

You may also use this call at any time to find out if Google Play Services are available and react to the result as necessary.

prompt install

statusCodes

These are useful when determining which kind of error has occured during sign in process. Import statusCodes along with GoogleSignIn. Under the hood these constants are derived from native GoogleSignIn error codes and are platform specific. Always prefer to compare error.code to statusCodes.SIGN_IN_CANCELLED or statusCodes.IN_PROGRESS and not relying on raw value of the error.code.

Name Description
SIGN_IN_CANCELLED When user cancels the sign in flow
IN_PROGRESS Trying to invoke another operation (e.g. signInSilently) when previous one has not yet finished. If you call e.g. signInSilently twice, 2 calls to signInSilently in the native module will be done. The promise from the first call to signInSilently will be rejected with this error, and the second will resolve / reject with the result of the native module.
SIGN_IN_REQUIRED Useful for use with signInSilently() - no user has signed in yet
PLAY_SERVICES_NOT_AVAILABLE Play services are not available or outdated, this can only happen on Android

Example how to use statusCodes.

2. GoogleSigninButton

signin button

import { GoogleSignin, GoogleSigninButton } from '@react-native-google-signin/google-signin';

<GoogleSigninButton
  size={GoogleSigninButton.Size.Wide}
  color={GoogleSigninButton.Color.Dark}
  onPress={this._signIn}
  disabled={this.state.isSigninInProgress}
/>;

Props

size

Possible values:

  • Size.Icon: display only Google icon. Recommended size of 48 x 48.
  • Size.Standard: icon with 'Sign in'. Recommended size of 230 x 48.
  • Size.Wide: icon with 'Sign in with Google'. Recommended size of 312 x 48.

Default: Size.Standard. Given the size prop you pass, we'll automatically apply the recommended size, but you can override it by passing the style prop as in style={{ width, height }}.

color

Possible values:

  • Color.Dark: apply a blue background
  • Color.Light: apply a light gray background
disabled

Boolean. If true, all interactions for the button are disabled.

onPress

Handler to be called when the user taps the button

3. userInfo

Example userInfo which is returned after successful sign in.

{
  idToken: string,
  serverAuthCode: string,
  scopes: Array<string>
  user: {
    email: string,
    id: string,
    givenName: string,
    familyName: string,
    photo: string, // url
    name: string // full name
  }
}

Jest module mock

If you use Jest for testing, you may need to mock the functionality of the native module. This library ships with a Jest mock that you can add to the setupFiles array in the Jest config.

By default, the mock behaves as if the calls were successful and returns mock user data.

"setupFiles": [
 "./node_modules/@react-native-google-signin/google-signin/jest/build/setup.js"
],

Want to contribute?

Check out the contributor guide!

Notes

Calling the methods exposed by this package may involve remote network calls and you should thus take into account that such calls may take a long time to complete (e.g. in case of poor network connection).

idToken Note: idToken is not null only if you specify a valid webClientId. webClientId corresponds to your server clientID on the developers console. It HAS TO BE of type WEB

Read iOS documentation and Android documentation for more information

serverAuthCode Note: serverAuthCode is not null only if you specify a valid webClientId and set offlineAccess to true. Once you get the auth code, you can send it to your backend server and exchange the code for an access token. Only with this freshly acquired token can you access user data.

Read iOS documentation and Android documentation for more information.

Additional scopes

The default requested scopes are email and profile.

If you want to manage other data from your application (for example access user agenda or upload a file to drive) you need to request additional permissions. This can be accomplished by adding the necessary scopes when configuring the GoogleSignin instance.

Please visit https://developers.google.com/identity/protocols/googlescopes or https://developers.google.com/oauthplayground/ for a list of available scopes.

Troubleshooting

Please see the troubleshooting section in the Android guide and iOS guide.

Licence

(MIT)

google-signin's People

Contributors

0xpatrickdev avatar adamperelman avatar adjective-object avatar alppu avatar andreicalazans avatar aniolpages avatar apfritts avatar arhmnsh avatar aziyatali avatar barbarosh avatar bitkidd avatar brentvatne avatar christophervalles avatar dabs avatar danilobuerger avatar ddave09 avatar dependabot[bot] avatar devfd avatar giautm avatar ifsnow avatar jozan avatar karlosq avatar kerumen avatar maggialejandro avatar ngraef avatar pjnovas avatar semantic-release-bot avatar silentchris avatar tvc97 avatar vonovak 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

google-signin's Issues

Null Pointer expection getSignInIntent(Unknown Source)

I'm a newbie to react native. Sorry, If it is a lame question. But, I followed all the steps mentioned in the readme file. I'm getting the following error.

 E/AndroidRuntime: FATAL EXCEPTION: main
 Process: com.witapp, PID: 9047
 java.lang.NullPointerException: null reference
                at com.google.android.gms.common.internal.zzx.zzy(Unknown Source)
                at com.google.android.gms.auth.api.signin.internal.zzc.getSignInIntent(Unknown Source)
                at co.apptailor.googlesignin.RNGoogleSigninModule$2.run(RNGoogleSigninModule.java:74)
                at android.os.Handler.handleCallback(Handler.java:739)
                at android.os.Handler.dispatchMessage(Handler.java:95)
                at android.os.Looper.loop(Looper.java:135)
                at android.app.ActivityThread.main(ActivityThread.java:5343)
                at java.lang.reflect.Method.invoke(Native Method)
                at java.lang.reflect.Method.invoke(Method.java:372)
                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)

Signin fails when webClientId is used and Google App is installed on device

Experiencing the same thing outlined here.

I have a webClientId setup and offlineAccess set to true. When a user has the Google App installed on their phone it will open that application for authentication. When it comes back to my app the sign in throws an error.

Everything works as expected on the simulator or when the user doesn't have the Google App (thus opening the web view for authentication). Everything also works fine when the offlineAccess is set to false.

It seems that app switching isn't recommended in by this comment.

I tried to dig into the package code but couldn't figure much out (unfamiliar with native ios development). Any help is greatly appreciated!

State doesn't change immediately upon signing in

I've setup what is in the example index.ios.js file. After tapping the sign in button, completing the flow, and returning to my app, the view doesn't update to reflect the current state where user is signed in. I need to reload the app in order for it to re-render with the new state.

A possibly related note is that after signing in, the 'Back to Google' link is still in the top left of the status bar.

Am I missing something?

Error on compiling for Android

Hey, thanks for this awesome lib!.

I'm configuring it for Android and I get an error when I run: react-native run-android:

Building and installing the app on the device (cd android && ./gradlew installDebug)...

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> A problem occurred configuring project ':react-native-google-signin'.
   > Could not resolve all dependencies for configuration ':react-native-google-signin:_debugCompile'.
      > Could not find com.google.android.gms:play-services-auth:8.3.0.
        Searched in the following locations:
            file:/home/pjnovas/.m2/repository/com/google/android/gms/play-services-auth/8.3.0/play-services-auth-8.3.0.pom
            file:/home/pjnovas/.m2/repository/com/google/android/gms/play-services-auth/8.3.0/play-services-auth-8.3.0.jar
            https://jcenter.bintray.com/com/google/android/gms/play-services-auth/8.3.0/play-services-auth-8.3.0.pom
            https://jcenter.bintray.com/com/google/android/gms/play-services-auth/8.3.0/play-services-auth-8.3.0.jar
            http://dl.bintray.com/mkonicek/maven/com/google/android/gms/play-services-auth/8.3.0/play-services-auth-8.3.0.pom
            http://dl.bintray.com/mkonicek/maven/com/google/android/gms/play-services-auth/8.3.0/play-services-auth-8.3.0.jar
            file:/home/pjnovas/adt-bundle-linux-x86_64-20131030/sdk/extras/android/m2repository/com/google/android/gms/play-services-auth/8.3.0/play-services-auth-8.3.0.pom
            file:/home/pjnovas/adt-bundle-linux-x86_64-20131030/sdk/extras/android/m2repository/com/google/android/gms/play-services-auth/8.3.0/play-services-auth-8.3.0.jar
        Required by:
            TourneyReact:react-native-google-signin:unspecified

I'm at Ubuntu 14.04 and Node 5.1.1
Any ideas?, thanks!

Android - Unable to login

I am unable to login on android, I can see popup asking for account. Then it don't print anything.

        DeviceEventEmitter.addListener('googleSignInError', (error) => {
          console.log('ERROR signin in', error);
        });

        DeviceEventEmitter.addListener('googleSignIn', (user) => {
          console.log(user);
        });

But i get following error when app starts

ERROR signin in Object {error: "SIGN_IN_REQUIRED", code: 4}

Android support

Now that react native is available to Android it would be great to have cross-platform support.

Dismiss sign-in event on user Cancel

I have a use-case where I would like to track if the user taps the Cancel button in the sign-in dialog.

In order to do this, would it be possible to send an event when dismissViewController is invoked?

It would be helpful to be able to distinguish if dismissViewController was called due to the user pressing Cancel or due to a successful sign in.

I am open to other ideas or options, but I thought having this would be useful.

play-services-auth:8.3.0 dependency issue

I've followed all of the steps in the instructions to get this setup with the Android environment (no issues in iOS) in React Native, but am getting the following error when running react-native run-android

Building and installing the app on the device (cd android && ./gradlew installDebug)...

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> A problem occurred configuring project ':react-native-google-signin'.
   > Could not resolve all dependencies for configuration ':react-native-google-signin:_debugCompile'.
      > Could not find com.google.android.gms:play-services-auth:8.3.0.
        Searched in the following locations:
            file:/Users/steven/.m2/repository/com/google/android/gms/play-services-auth/8.3.0/play-services-auth-8.3.0.pom
            file:/Users/steven/.m2/repository/com/google/android/gms/play-services-auth/8.3.0/play-services-auth-8.3.0.jar
            https://jcenter.bintray.com/com/google/android/gms/play-services-auth/8.3.0/play-services-auth-8.3.0.pom
            https://jcenter.bintray.com/com/google/android/gms/play-services-auth/8.3.0/play-services-auth-8.3.0.jar
            file:/usr/local/opt/android-sdk/extras/android/m2repository/com/google/android/gms/play-services-auth/8.3.0/play-services-auth-8.3.0.pom
            file:/usr/local/opt/android-sdk/extras/android/m2repository/com/google/android/gms/play-services-auth/8.3.0/play-services-auth-8.3.0.jar
        Required by:
            PowerToolSafe:react-native-google-signin:unspecified

I've added the following to the top-level build.gradle:

'com.google.gms:google-services:1.5.0'

And the following to the app-level build.gradle:

apply plugin: 'com.google.gms.google-services'
 ...
 dependencies {
     ...
     compile project(":react-native-google-signin")
}

I've tried different versions of google-services but end up still getting the build error. In JCenter I don't even see com/google/android/gms/play-services-auth.

Thanks!

undefined is not an object (evaluating 'RNGoogleSignin.BUTTON_SIZE_ICON')

I've just installed this library by running

npm install react-native-google-signin --save

I have the following at the top of my react script:

'use strict';
var React = require('react-native');
var {
  StyleSheet,
  Component,
  View,
  Text,
  TouchableOpacity,
  Navigator,
  TextInput
} = React;

and I then appended

import {GoogleSignin, GoogleSigninButton} from 'react-native-google-signin';

I then pressed Run in XCode and it throws the following error

undefined is not an object (evaluating 'RNGoogleSignin.BUTTON_SIZE_ICON')

If I remove

import {GoogleSignin, GoogleSigninButton} from 'react-native-google-signin';

the error is not thrown.

How do you run the example project included?

We've been trying getting the example to run on both Android and iOS simulator with
no luck so far. What are we missing? Been running the app straight from the react-native-google-signin/example folder

For iOS the simulator complains: "Could not connect to development server".
Tried to launch it from VScode using debug iOS. Also tried react-native start from terminal.

Please include some basic getting started instructions for newbies.
Not even sure what to use the iOS guide for... I assume this is a guide for how to integrate this plugin into existing project, not running any of the examples.

Please help get us going. Thanks :)

Android INTERNAL_ERROR code: 8

Hello. Help me please. I've implemented your module: on android 4.4.2 it works perfectly, but if I try on 5.0.1 I got GoogleSigninError INTERNAL_ERROR code: 8.
RN v0.23
RN-google-signin: v0.4.3

I checked everythin from #35 issue, maybe you found correct solution for that, I hope.
Thanks

Token value is always returning null

I want to authenticate with backend server. For that, I need to send the token value to the backend server. But, I'm always getting null value in the token field. When I was searching in google, I found this.

You must configure Google Sign-In with the requestIdToken method to successfully call getIdToken. If you do not configure Google Sign-In to request ID tokens, the getIdToken method returns null.

Source : https://developers.google.com/identity/sign-in/android/backend-auth

This is not an issue. This is feature request. But, I couldn't add label here. Thanks.

size and color don't work on android

Hi,

I've noticed the properties "Size" and "Color" are not working on android (I've not tested on ios).

snippet to reproduce it:

  <GoogleSigninButton
    style={{width: 140, height: 48}}
    size={GoogleSigninButton.Size.Wide} // ignoring this value
    color={GoogleSigninButton.Color.Dark} // ignoring this value as well
    onPress={this._signIn.bind(this)}/>

P.s. : running it on react-native 0.22.2

Cheers,
Paulo

wrong sign in internal error

while integrating google login says wrong sign in what's going wrong for me react-native 0.21.0 react-native-google-signin": "0.4.0" I have set my configuration google-services correct

I have also tried the example given by react-native-google-signin .The same issue
continues . So please guide me.

Herewith I have provided with the error screenshot.

WRONG SIGNIN Error: unknown status code: 12501
    at GoogleSigninError.Error (native) 

Please support me
Thanks in advance

Caching access tokens for reuse

This is not a bug; more of a question to see what ideas are used out there.

When a user logs in via google-signin, a user object is returned similar to the following:

accessToken: "ya29.hQJD767t_-geYHlFUyW9CCAGBC"
accessTokenExpirationDate: 3599.984444022179
email: "[email protected]"
id: "1003109889901343"
idToken: "eyJhbGciOiJSUzI1NiIsImtpZCI6ImYwMmZkODgwOTNmNTQ2Mjg1MD"
name: "My name"
photo: "https://lh5.googleusercontent.com/-/8elejb5_N1A/s120/photo.jpg"
serverAuthCode: "4/4eGtD4XPGKnIGxUUVhVe96XYBz11Y"

The accessToken is what I use when invoking various google api endpoints which I plan to be doing fairly frequently whilst the user is using my app.

Is it expected that I cache this user object for 3599 seconds before needing to re-sign the user? Or would I call a google endpoint to refresh the token, and aim to keep the token alive all the time?

Thoughts?

RNGoogleSignin was called with 3 arguments but expects 2 on iOS

image

I'm not sure how this gets called, but it works for me on android fine. II'm pretty much following the example...

  componentDidMount() {
    GoogleSignin.configure({
      scopes: [],
      iosClientId: 'myiosid',
      webClientId: 'mywebid',
      offlineAccess: false
    });

    GoogleSignin.currentUserAsync().then((user) => {
      console.log('USER', user);
      this.setState({user: user});
    }).done();
  }

rn 0.18.1, xcode 7.2, react-native-google-signin 0.4.0

Access Token

Why does iOS return an access token and Android does not? I'm just learning about the Google APIs...How do I get an access token / make requests after I've properly authenticated with this module? I'm specifically trying to utilize the Google Calendar API after authenticating. Thanks in advance.

npm install error

npm install react-native-google-signin
npm ERR! cb() never called!

getPhotoUrl NullPointerException in Android for Hosted Domain Accounts

If a user tries to log in using a domain hosted by google, and also does not have a profile picture associated with their account, a NullPointerException is thrown at acct.getPhotoUrl().toString());

This error only occurs on Android (not iOS).

I am running version 0.3.1 with react native 0.18.0-rc

Here's a sample stack trace:

FATAL EXCEPTION: main
  Process: com.example.app, PID: 2734
  java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=9001, result=-1, data=Intent { (has extras) }} to activity {com.example.app/com.example.app.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.net.Uri.toString()' on a null object reference
      at android.app.ActivityThread.deliverResults(ActivityThread.java:3699)
      at android.app.ActivityThread.handleSendResult(ActivityThread.java:3742)
      at android.app.ActivityThread.-wrap16(ActivityThread.java)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1393)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loop(Looper.java:148)
      at android.app.ActivityThread.main(ActivityThread.java:5417)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
   Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.net.Uri.toString()' on a null object reference
      at co.apptailor.googlesignin.RNGoogleSigninModule.handleSignInResult(RNGoogleSigninModule.java:169)
      at co.apptailor.googlesignin.RNGoogleSigninModule.onActivityResult(RNGoogleSigninModule.java:119)
      at com.example.app.MainActivity.onActivityResult(MainActivity.java:31)
      at android.app.Activity.dispatchActivityResult(Activity.java:6428)
      at android.app.ActivityThread.deliverResults(ActivityThread.java:3695)
      at android.app.ActivityThread.handleSendResult(ActivityThread.java:3742) 
      at android.app.ActivityThread.-wrap16(ActivityThread.java) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1393) 
      at android.os.Handler.dispatchMessage(Handler.java:102) 
      at android.os.Looper.loop(Looper.java:148) 
      at android.app.ActivityThread.main(ActivityThread.java:5417) 
      at java.lang.reflect.Method.invoke(Native Method) 
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Generate Bitcode for react-native-google-signin

Would it be possible to alter the build of react-native-google-signin to include Bitcode?

Currently I have to disabled Bitcode for my whole project as a result which is something I'd prefer not to do as you obviously lose the benefits that Apple provide when using Bitcode

Update to the Google Sign-In iOS SDK 3.0.0

I believe the reason for #52 is due to the SDK version. Using 3.0.0, the sign-in page does not flip to safari. Would you consider updating to 3.0.0?

I gave it a quick try and there were no code changes needed (at least on my setup). The only changes I had to make were:

  • StoreKit.framework is no longer necessary
  • SafariServices.framework needs to be linked
  • Bitcode can be enabled.

Full changes are:
https://developers.google.com/identity/sign-in/ios/release#2016-03-22_--_v300

Build on device Error - ENABLE_BITCODE

When I try to build on a device with iOS 9.0 (simulator works fine) I get the following error:

ld: 'PROJ_PATH/node_modules/react-native-google-signin/RNGoogleSignin/GoogleSignIn.framework/GoogleSignIn(GTMABAddressBook.o)' does not contain bitcode.
You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

[iOS] No data replied from SignIn function

Hi, thanks for this component, it was working in my project,
but something got strange recently in my iOS simulator: after filling the username/password form,
clicking on "Allow" button,
and confirm dialog of "Open this page in 'YourAppName'?" ,
even though my user is available in safari, but there's no data reply to my app, the error log says:

Apr 2 00:22:27 VBElCapitan MobileSafari[1051]: Snapshotting a view that has not been rendered results in an empty snapshot. Ensure your view has been rendered at least once before snapshotting or snapshot after screen updates.
Apr 2 00:22:29 VBElCapitan assertiond[926]: assertion failed: 15A282b 13E5225a: assertiond + 16726 [8FC7066F-814E-3544-8332-F9079B87DFEF]: 0x1
Apr 2 00:22:29 ElCapitan assertiond[926]: Requesting process (<BKNewProcess: 0x7967ffc0; com.apple.mobilesafari; pid: 1051; hostpid: -1>) is suspended and cannot obtain assertions
Apr 2 00:22:29 ElCapitan SpringBoard[922]: [MPUSystemMediaControls] Updating supported commands for now playing application.
Apr 2 00:22:34 ElCapitan MobileSafari[1051]: Can't endBackgroundTask: no background task exists with identifier 86, or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.
Apr 2 00:23:24 ElCapitan routined[911]: CoreLocation: Error occurred while trying to retrieve motion state update: CMErrorDomain Code:104
Apr 2 00:23:37 ElCapitan assertiond[926]: assertion failed: 15A282b 13E5225a: assertiond + 16726 [8FC7066F-814E-3544-8332-F9079B87DFEF]: 0x1

is it a xcode problem or a simulator issue? or maybe I need to change anything in codes/settings ?
I run the example again, without any problem, but it happened again when I re-add it into my project
Thanks a lot

Android - React 0.21.0 - INTERNAL_ERROR

Getting this error on Android. This shows when I click a button that runs GoogleSignin.signIn(). It doesn't make it to the login view at all, just errors out. I have my debug token set as the fingerprint, not sure what else to check?

Error: INTERNAL_ERROR
    at GoogleSigninError.Error (native)
    at new GoogleSigninError (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false:93823:188)
    at http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false:93875:8
    at EventEmitter.emit (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false:50043:23)
    at MessageQueue.__callFunction (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false:48673:23)
    at http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false:48577:8
    at guard (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false:48531:1)
    at MessageQueue.callFunctionReturnFlushedQueue (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false:48576:1)
    at DedicatedWorkerGlobalScope.onmessage (http://localhost:8081/debuggerWorker.js:39:56)

Domain=com.google.GIDSignIn Code=-4

Pretty sure I have everything configured correctly - when I load the app and login, I get the following error. I only get it once - afterwards, I will get the login button but clicking it will do nothing and I have to restart the simulator. Any idea what might be causing this?

I see this error in XCode - nothing on the react terminal.

2015-11-26 10:19:12.059 [info][tid:com.facebook.React.JavaScript] 'ERROR signin in', { error: 'Error Domain=com.google.GIDSignIn Code=-4 "(null)"' }
2015-11-26 10:20:10.269 blueprintNative[23369:2586201] LaunchServices: ERROR: There is no registered handler for URL scheme com-google-gidconsent-google
2015-11-26 10:20:10.271 blueprintNative[23369:2586201] LaunchServices: ERROR: There is no registered handler for URL scheme com-google-gidconsent
2015-11-26 10:20:10.271 blueprintNative[23369:2586201] LaunchServices: ERROR: There is no registered handler for URL scheme com.google.gppconsent.2.4.1
2015-11-26 10:20:10.272 blueprintNative[23369:2586201] LaunchServices: ERROR: There is no registered handler for URL scheme com.google.gppconsent.2.4.0

iOS signin is not secure

It looks like GoogleSignin.framework uses by default oauth2 implcit grant type, which is not secure - it means that accessToken is just returned with the redirection from authorization server (easy to sniff) instead of manually obtained server side using one-time server auth code and secret.

It would be good to change it, it will also be consistent with how Android version works.

Theoretically here is documentation how to do this:
https://developers.google.com/identity/sign-in/ios/offline-access

I just wanted to do pull request with these changes, but for some reason I'm still getting accessToken and no user.serverAuthCode.

Exception in native call from JS?

I am getting this error when trying to run my app with google signin. I dont feel like I've done anything different than the instructions and I folllowed the example in my js. Any help with this is greatly appreciated!

01-27 11:16:36.949 14644-14666/? E/unknown:React: Exception in native call from JS
01-27 11:16:36.949 14644-14666/? E/unknown:React: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context com.google.android.gms.common.api.GoogleApiClient.getContext()' on a null object reference
01-27 11:16:36.949 14644-14666/? E/unknown:React:     at com.google.android.gms.auth.api.signin.internal.zzc.signOut(Unknown Source)
01-27 11:16:36.949 14644-14666/? E/unknown:React:     at co.apptailor.googlesignin.RNGoogleSigninModule.signOut(RNGoogleSigninModule.java:82)
01-27 11:16:36.949 14644-14666/? E/unknown:React:     at java.lang.reflect.Method.invoke(Native Method)
01-27 11:16:36.949 14644-14666/? E/unknown:React:     at java.lang.reflect.Method.invoke(Method.java:372)
01-27 11:16:36.949 14644-14666/? E/unknown:React:     at com.facebook.react.bridge.BaseJavaModule$JavaMethod.invoke(BaseJavaModule.java:249)
01-27 11:16:36.949 14644-14666/? E/unknown:React:     at com.facebook.react.bridge.NativeModuleRegistry$ModuleDefinition.call(NativeModuleRegistry.java:158)
01-27 11:16:36.949 14644-14666/? E/unknown:React:     at com.facebook.react.bridge.NativeModuleRegistry.call(NativeModuleRegistry.java:58)
01-27 11:16:36.949 14644-14666/? E/unknown:React:     at com.facebook.react.bridge.CatalystInstanceImpl$NativeModulesReactCallback.call(CatalystInstanceImpl.java:430)
01-27 11:16:36.949 14644-14666/? E/unknown:React:     at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
01-27 11:16:36.949 14644-14666/? E/unknown:React:     at android.os.Handler.handleCallback(Handler.java:739)
01-27 11:16:36.949 14644-14666/? E/unknown:React:     at android.os.Handler.dispatchMessage(Handler.java:95)
01-27 11:16:36.949 14644-14666/? E/unknown:React:     at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
01-27 11:16:36.949 14644-14666/? E/unknown:React:     at android.os.Looper.loop(Looper.java:135)
01-27 11:16:36.949 14644-14666/? E/unknown:React:     at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:184)
01-27 11:16:36.949 14644-14666/? E/unknown:React:     at java.lang.Thread.run(Thread.java:818)

Get Current accessToken

the only way to get the current access token is to listen to googleSignIn and cache the value.
this event is called after signin and when re-launching the app when you're already signed in.
I would like to be able to do the following:

GoogleSignin.getCurrentAccessToken((token)=> {
      console.log(token);
});

Error "unknown status code: 12501" when using clientID

Without providing client Id to GoogleSignin.configure plugin works well. But when i pass this parameter, i get the "unknown status code: 12501". I learned that this error may come from wrong configuration, but...
The client Id i get from google developers console (New credentials -> OAuth ClientID -> Android). SHA-1 signing-certificate fingerprints specified correctly (fingerprint from ~/.android/debug.keystore matches to that specified in android/app/google-services.json and this key definitely used to sign my debug apk). Also client_id in google-services.json matches to that i pass to GoogleSignin.configure.
Any thoughts?

Android 6.0.1, [email protected], [email protected]

IOS - setting documentation (add to docs multiple using objective C class)

//facebook & Google Auth----------------------------------------------------------------

  • (BOOL)application:(UIApplication *)application
    openURL:(NSURL *)url
    sourceApplication:(NSString *)sourceApplication
    annotation:(id)annotation {

    if ([RNGoogleSignin application:application openURL:url sourceApplication:sourceApplication annotation:annotation]) return YES;
    return [[FBSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
    }
    // native Event when app go from background to foreground

  • (void)applicationDidBecomeActive:(UIApplication *)application {
    [FBSDKAppEvents activateApp];
    }
    //facebook & Google Auth-----------------------------------------------------------------

Android Error: INTERNAL_ERROR (Code: 8)

Running into an INTERNAL_ERROR (Code: 8) when trying to log in.

Current setup:
RN: 0.19
RN-google-signin: 0.4.0

Trying on Google Nexus 6 (6.0.0 - API 23).

I've got an API key created based on the Android debug.keystore, as well as OAuth client IDs for both Android and Web types. I've tried the both ClientIDs in my GoogleSignin.configure() call, but both yield the same error. The package names between the Android API and OAuth configs are the same, and they match the AndroidManifest too.

Not sure if there's anything else I can try to debug?

Thanks!

Error when running on device

Works fine in the simulator, but running on device I get an exception stating my app 'should support the following URL types' and then lists the url types which I have already entered into the config.

Trouble with silent sign in on ios [0.4.0]

First, thanks for the package. It's saved me a lot of time.

I'm finding that after updating to 0.4.0 the silent sign in isn't working consistently/at all. I was looking through the source and I saw that with Android you're listening for a RNGoogleSignInSilentSuccess event whereas on ios there is no mention of that event.

I'm not familiar with objective c or java though so I could be totally off here. Any help would be appreciated!

One thing I should note is that I do have login working fine. I'm able to login with email and password and after I've logged in once all I have to do in subsequent requests is press "Allow". It doesn't require me to enter my email/password again.

Problem: missing support for URL scheme (bundleId)

I tried to follow the iOS guide to the point.

add a URL with scheme set to your bundle id

My bundle identifier on the general tab is set to: com.tecla5.chat

I created a URL scheme with com.tecla5.chat for both Identifier and URL scheme but for some reason it expects the reverse, chat.tecla5.com.

If I change the URL scheme to this form, it also errors. What is the deal (correct settings) here? What could I be missing?

When I click the Login button I get this error:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Your app is missing support for the following URL schemes: chat.tecla5.com'

error when copying example verbatim: undefined is not an object (evaluating 'GoogleSignin.configure')?

I believe I have copied everything from the example, I've gone through it a couple times now, but I am getting this error when the GoogleSignin object is called. Am I missing something? Has anyone else had this happen?

here is my log currently if it helps at all:

2015-11-30 14:11:15.846 [error][tid:com.facebook.React.JavaScript] 
'Error: undefined is not an object (evaluating \'GoogleSignin.configure\')\n stack: \n  _configureOauth  
index.ios.bundle?…:971\n  componentDidMount 
index.ios.bundle?…:926\n  notifyAll
index.ios.bundle?…:3800\n  close
index.ios.bundle?…:14517\n  closeAll
index.ios.bundle?…:4513\n  perform
index.ios.bundle?…:4454\n  batchedMountComponentIntoNode
index.ios.bundle?…:10032\n  perform
index.ios.bundle?…:4440\n  batchedUpdates
index.ios.bundle?…:14299\n  batchedUpdates
index.ios.bundle?…:3570\n  renderComponent
index.ios.bundle?…:10116\n  ReactMount__renderNewRootComponent  
index.ios.bundle?…:2834\n  render                              
index.ios.bundle?…:1212\n  renderApplication                   
index.ios.bundle?…:46702\n  run                                 
index.ios.bundle?…:46592\n  runApplication                      
index.ios.bundle?…:46620\n  __callFunction                     
index.ios.bundle?…:2574\n  <unknown>                           
index.ios.bundle?…:2500\n  guard                               
index.ios.bundle?…:2459\n  callFunctionReturnFlushedQueue      
index.ios.bundle?…:2499\n URL: http://localhost:8081/index.ios.bundle?platform=ios&dev=true\n line: 971\n message: undefined is not an object (evaluating \'GoogleSignin.configure\')'

Thank you for any help you can provide

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.