Security News
New Proposed CISA Mandate Would Require Critical Infrastructure to Report Ransom Payments Within 24 Hours
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
react-native-google-sign-in
Advanced tools
React Native Wrapper for Google Sign-In OAuth SDK / API
Weekly downloads
Readme
https://github.com/devfd/react-native-google-signin is not working and is not being maintained anymore (See Issue), so I created this one myself. It uses the latest Google Sign-In SDK.
For LinkedIn SDK, check out joonhocho/react-native-linkedin-sdk
Tested with React Native 0.39 and 0.40. Also, see Tested Environments. Let me know if some instructions are missing.
$ react-native install react-native-google-sign-in
Follow Google's official instructions for Android.
Follow everything from the instructions with the following modifications.
Some of the following modifications should be done by react-native install
automatically. If not, do it yourself:
Move google-services.json
to {YourApp}/android/app/google-services.json
.
Add to your {YourApp}/android/settings.gradle
:
include ':react-native-google-sign-in'
project(':react-native-google-sign-in').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-google-sign-in/android')
{YourApp}/android/build.gradle
:dependencies {
classpath 'com.android.tools.build:gradle:2.2.3' // This may need to be updated to >= 2.2.3.
classpath 'com.google.gms:google-services:3.0.0' // Add this
}
{YourApp}/android/app/build.gradle
:dependencies {
compile(project(":react-native-google-sign-in")) { // ADD this
exclude group: "com.google.android.gms"
}
...your modules...
compile "com.google.android.gms:play-services-auth:10.0.1" // Add this, not 9.8.0 (from instructions).
compile "com.facebook.react:react-native:+"
}
apply plugin: "com.google.gms.google-services" // Add this after dependencies.
{YourApp}/android/app/src/main/java/com/{YourApp}/MainApplication.java
:import com.reactlibrary.googlesignin.RNGoogleSignInPackage; // Add this.
...in your class MainApplication...
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RNGoogleSignInPackage(), // Add this.
...other packages...
);
}
YourApp.xcworkspace
, not YourApp.xcodeproj
, with Xcode to run the app.Add files to '{YourApp}'
.{YourApp}/node_modules/react-native-google-sign-in/ios/RNGoogleSignIn
.Build Settings
.Header Search Paths
.$(SRCROOT)/../node_modules/react-native-google-sign-in/ios/RNGoogleSignIn
.Add to your {YourApp}/ios/{YourApp}/AppDelegate.m
:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSError* configureError;
[[GGLContext sharedInstance] configureWithError: &configureError];
NSAssert(!configureError, @"Error configuring Google services: %@", configureError);
...add above codes
}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
BOOL handled = [[GIDSignIn sharedInstance] handleURL:url
sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
annotation:options[UIApplicationOpenURLOptionsAnnotationKey]];
return handled;
}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
if ([[GIDSignIn sharedInstance] handleURL:url
sourceApplication:sourceApplication
annotation:annotation]) {
return YES;
}
return YES;
}
Add to your {YourApp}/ios/{YourApp}/AppDelegate.h
:
#import <Google/SignIn.h>
Add to your Swift Bridging Header, {YourApp}/ios/{YourApp}-Bridging-Header.h
:
#import <React/RCTBridgeModule.h>
#import <React/RCTViewManager.h>
#import <React/RCTEventEmitter.h>
#import <Google/SignIn.h>
Or, if you are using RN <= 0.39:
#import "RCTBridgeModule.h"
#import "RCTViewManager.h"
#import "RCTEventEmitter.h"
#import <Google/SignIn.h>
import GoogleSignIn from 'react-native-google-sign-in';
// later in your code...
async yourMethod() {
await GoogleSignIn.configure({
// iOS
clientID: 'yourClientID',
// iOS, Android
// https://developers.google.com/identity/protocols/googlescopes
scopes: ['your', 'requested', 'api', 'scopes'],
// iOS, Android
// Whether to request email and basic profile.
// [Default: true]
// https://developers.google.com/identity/sign-in/ios/api/interface_g_i_d_sign_in.html#a06bf16b507496b126d25ea909d366ba4
shouldFetchBasicProfile: boolean,
// iOS
// https://developers.google.com/identity/sign-in/ios/api/interface_g_i_d_sign_in.html#a486c8df263ca799bea18ebe5430dbdf7
language: string,
// iOS
// https://developers.google.com/identity/sign-in/ios/api/interface_g_i_d_sign_in.html#a0a68c7504c31ab0b728432565f6e33fd
loginHint: string,
// iOS, Android
// https://developers.google.com/identity/sign-in/ios/api/interface_g_i_d_sign_in.html#ae214ed831bb93a06d8d9c3692d5b35f9
serverClientID: 'yourServerClientID',
// Android
// Whether to request server auth code. Make sure to provide `serverClientID`.
// https://developers.google.com/android/reference/com/google/android/gms/auth/api/signin/GoogleSignInOptions.Builder.html#requestServerAuthCode(java.lang.String, boolean)
offlineAccess: boolean,
// Android
// Whether to force code for refresh token.
// https://developers.google.com/android/reference/com/google/android/gms/auth/api/signin/GoogleSignInOptions.Builder.html#requestServerAuthCode(java.lang.String, boolean)
forceCodeForRefreshToken: boolean,
// iOS
// https://developers.google.com/identity/sign-in/ios/api/interface_g_i_d_sign_in.html#a211c074872cd542eda53f696c5eef871
openIDRealm: string,
// Android
// https://developers.google.com/android/reference/com/google/android/gms/auth/api/signin/GoogleSignInOptions.Builder.html#setAccountName(java.lang.String)
accountName: 'yourServerAccountName',
// iOS, Android
// https://developers.google.com/identity/sign-in/ios/api/interface_g_i_d_sign_in.html#a6d85d14588e8bf21a4fcf63e869e3be3
hostedDomain: 'yourHostedDomain',
});
const user = await GoogleSignIn.signInPromise();
console.log(user);
}
See js/GoogleSignIn.ios.js for supported iOS APIs.
See js/GoogleSignIn.android.js for supported Android APIs.
I only tested with the following environments:
The MIT License (MIT)
Copyright (c) 2017 Joon Ho Cho
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
FAQs
React Native Wrapper for Google Sign-In OAuth SDK / API
The npm package react-native-google-sign-in receives a total of 5 weekly downloads. As such, react-native-google-sign-in popularity was classified as not popular.
We found that react-native-google-sign-in demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
Security News
Redis is no longer OSS, breaking its explicit commitment to remain under the BSD 3-Clause License forever. This has angered contributors who are now working to fork the software.
Product
Socket AI now enables 'AI detected potential malware' alerts by default, ensuring users benefit from AI-powered state-of-the-art malware detection without needing to opt-in.