Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tsamaya/passport-example-with-google-oauth2
a Passport example using an Express with Google OAuth2
https://github.com/tsamaya/passport-example-with-google-oauth2
bulma express google javascript oauth2 passport tutorial
Last synced: about 2 months ago
JSON representation
a Passport example using an Express with Google OAuth2
- Host: GitHub
- URL: https://github.com/tsamaya/passport-example-with-google-oauth2
- Owner: tsamaya
- License: mit
- Created: 2018-03-17T16:48:08.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-03-02T06:45:12.000Z (almost 2 years ago)
- Last Synced: 2024-05-02T04:34:36.514Z (8 months ago)
- Topics: bulma, express, google, javascript, oauth2, passport, tutorial
- Language: JavaScript
- Homepage:
- Size: 1.4 MB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# passport-example-with-google-oauth2
This repository is a [Passport](http://www.passportjs.org/) example using an [Express](http://expressjs.com/) application with an authentication using Google-OAuth2 authorization.
## Usage
#### Create an OAuth 2.0 client ID
First, create a project at [console.developers.google.com](https://console.developers.google.com)
*Create authorization credentials*
1. Open the [Credentials page](https://console.developers.google.com/apis/credentials) in the API Console.
![Google console](./resources/googlecredentials.png)
2. Fill the form for in the _Oauth consent screen_ tab, only the *Product name shown to users* is mandatory
![Google console](./resources/googleconsentscreen.png)
3. Back in _Credentials_ tab, Click *Create credentials > OAuth client ID*.
4. Complete the form. Set the application type to Web application. Fill the *Authorized redirect URIs*, here with our local server use `http://127.0.0.1:3000/auth/google/callback`.
5. click *Create*
*Enable Google+ Library*
1. Open the [Library page](https://console.developers.google.com/apis/library) in the API console.
2. Search for *Google+ API*
![Google console](./resources/googlesearchlibrary.png)
3. Enable this API
![Google console](./resources/googleenablegoogleplus.png)
#### Configure Strategy
create a `.env` file with:
```
GOOGLE_CLIENT_ID=YOUR-CLIENT-ID
GOOGLE_CLIENT_SECRET=YOUR-CLIENT-SECRET
```#### Install dependencies
```sh
$ npm install
```or
```sh
$ yarn
```#### Run
```sh
$ npm start
```or
```sh
$ yarn start
```open your browser on [localhost:3000](http://localhost:3000)
![Home](./resources/pleaselogin.png)
## Resources
- Passport [Facebook example](https://github.com/passport/express-4.x-facebook-example) from [@jaredhanson](https://github.com/jaredhanson)
- [Bulma](https://bulma.io/) CSS framework based on Flexbox, from [@jgthms](https://github.com/jgthms)## Contributing
Anyone and everyone is very welcome to contribute.## Issues
Find a bug or want to request a new feature? Please let me know by submitting an issue.## Licensing
Licensed under the MIT LicenseA copy of the license is available in the repository's [LICENSE](LICENSE) file.