Git Product home page Git Product logo

react-google-login's Introduction

React Google Login

Create a react app to login with google account. In this tutorial you will:

  • save login data in local storage to remember user login
  • create backend api using node and express to authenticate user
  • publish on heroku and test it on production

Run it locally

How to implement

frontend:

  1. npx create-react-app react-google-login
  2. npm install react-google-login
  3. edit App.js
  4. create h1 for app name.
  5. define loginData state hook
  6. check loginData and render content
  7. if loginData is null render GoogleLogin component
  8. if loginData isn't null render you are logged in message.
  9. implement handleLogout
  10. implement handleFailure
  11. implement handleLogin

google cloud platform

  1. login to google
  2. go to https://console.cloud.google.com
  3. create a project
  4. go to api credential
  5. accept consent screen
  6. craete oauth client id
  7. craete .env file and save it as REACT_APP_GOOGLE_CLIENT_ID

backend:

  1. create server.js file
  2. npm install express dotenv google-auth-library
  3. config dotenv
  4. create OAuth2Client client
  5. create express server
  6. use express.json()
  7. define app.post('/api/google-login', ...
  8. define app.listen

heroku publish

  1. create Procfile
  2. create app.use(express.static
  3. app.get('*',
  4. commit changes
  5. publish to github
  6. create heroku account and app
  7. connect it to github repo

react-google-login's People

Contributors

basir 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

Watchers

 avatar  avatar  avatar

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.