Code Monkey home page Code Monkey logo

reactgooglesignin's Introduction

ReactGoogleSignIn

A React component that will allow you to integrate Google sign in and sign out to your app.

How to install

    npm install react-google-signin 

How to use

    import React from 'react';
    import GoogleSignIn from "react-google-signin";
    
    
    class Home extends React.Component { 
    
    
        onSignIn(userProfile, accessToken) {
            console.log(userProfile)
        }
        
        signOut() {
            this.googleAuth.signOut();
        }
    
        render() {
            return (
                <GoogleSignIn clientId="YOUR_CLIENT_ID"
            			  ref={g => this.googleAuth = g}
            			  onSuccess={this.onSignIn.bind(this)}
                />
                
                <button onClick={this.signOut.bind(this)}> Sign Out </button>  
            );    
        }
 
    }

Props

clientId required

type: String

Create your Google API Console Project and Client ID and specify the client id as this prop. To create Client ID: https://developers.google.com/identity/sign-in/web/devconsole-project

onSuccess required

type: Function

onSuccess callback function will be called with userProfile and accessToken. AccessToken will be sent only when needAccess prop is set to true

userProfile = {
  id: ID 
  name: NAME
  givenName: GIVENNAME
  familyName: FAMILYNAME
  email: EMAIL
  imageUrl: IMAGEURL      
}

onFailure optional

type: Function

onFailure callback function will be called with error object when sign in fails

scope optional

type: String, defaultValue: profile email

needAccess optional

type: Boolean defaultValue: false

The value true will allow you to get the access token as a second parameter in onSuccess callback

width optional

type: number defaultValue: 240

Sets the width of the sign in button

height optional

type: number defaultValue: 50

Sets the height of the sign in button

theme optional

type: String defaultValue: dark

Sets the theme of the signin button

reactgooglesignin's People

Contributors

maheshkkolla avatar

Stargazers

Krishna Kumar Thokala avatar

Watchers

James Cloos avatar  avatar

reactgooglesignin's Issues

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.