Giter Club home page Giter Club logo

google-api-nodejs-client-sample's Introduction

Google Oauth Api Usage

This repo goal is to have several examples that helps to development team which works with google oauth.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

What things you need to install the software and how to install them

Google console configurations

Creating A Google Project With The Google API Console

Follow this intructions : http://support.wpsocial.com/support/solutions/articles/144223-creating-a-google-project-with-the-google-api-console

In the section of urls, put this

3000 port is referencial, you could choice your own port with PORT variable

app.listen(process.env.PORT || my_port);

Update credentials and scope

Export this values:

export CLIENT_ID="****"
export CLIENT_SECRET="****"
export REDIRECT_URI="****"
export SCOPE="profile https://www.googleapis.com/auth/userinfo.email"
export PORT=3000

Note: In this example, with these scopes, google just allow us to read a minimal user information.

Run

Launch demo-oauth.js with one of these commands :

npm run start
node demo-oauth.js

If no errors in log, go to your browser and launch

http://localhost:3000/health

And you will get

Im ready to use!!

Endpoints

Step endpoint description
01 : Get oauth code http://localhost:3000/code this will redirect to login or acceptance google form. If no errors, code will be printed
02 : Exchange oauth code for the access_token http://localhost:3000/access_token?code=abcdefghi abcdefghi must be the value returned in step 1
03 : Exchange oauth access_token for the email http://localhost:3000/email?access_token=123456789 123456789 must be the value returned in step 2

Note

  • code value returned in step 1, works just one time. You will need to consume /code for every time yo test the step 2 or step 3

Versioning

1.0.0

Authors

  • Richard Leon Ingaruca - Initial work - Jrichardsz

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

google-api-nodejs-client-sample's People

Contributors

fertejada avatar jrichardsz avatar rleoning avatar

Stargazers

 avatar  avatar

Watchers

 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.