{"id":14957625,"url":"https://github.com/gasparrobi/node-google-oauth2-jwt","last_synced_at":"2025-07-12T04:40:32.764Z","repository":{"id":65402090,"uuid":"119105540","full_name":"gasparrobi/node-google-oauth2-jwt","owner":"gasparrobi","description":"sample nodejs api with mongodb and passportjs authentication, (google-oauth2, jwt)","archived":false,"fork":false,"pushed_at":"2020-02-08T07:31:56.000Z","size":49,"stargazers_count":46,"open_issues_count":0,"forks_count":14,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-29T23:14:51.047Z","etag":null,"topics":["es6","express-js","expressjs","jwt","mongodb","mongoose","nodejs","passport-google","passportjs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gasparrobi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-26T21:32:13.000Z","updated_at":"2024-06-26T12:34:12.000Z","dependencies_parsed_at":"2023-01-23T02:45:34.562Z","dependency_job_id":null,"html_url":"https://github.com/gasparrobi/node-google-oauth2-jwt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gasparrobi%2Fnode-google-oauth2-jwt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gasparrobi%2Fnode-google-oauth2-jwt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gasparrobi%2Fnode-google-oauth2-jwt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gasparrobi%2Fnode-google-oauth2-jwt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gasparrobi","download_url":"https://codeload.github.com/gasparrobi/node-google-oauth2-jwt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224305845,"owners_count":17289446,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["es6","express-js","expressjs","jwt","mongodb","mongoose","nodejs","passport-google","passportjs"],"created_at":"2024-09-24T13:15:15.410Z","updated_at":"2024-11-12T16:04:48.212Z","avatar_url":"https://github.com/gasparrobi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-google-oauth2-jwt\n\n|                                                  nodejs                                                  |                                       express                                       |                                                      mongodb                                                       |                                                      passport                                                       |                                                    jwt                                                    |                                                           oauth2                                                            |                                        googleAuth                                        |\n| :------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------: |\n| \u003cimg align='center' src=\"https://nodejs.org/static/images/logos/nodejs-new-pantone-black.png\" width=100\u003e | \u003cimg align='center' src=\"https://i.cloudup.com/zfY6lL7eFa-3000x3000.png\" width=150\u003e | \u003cimg align='center' src=\"https://webassets.mongodb.com/_com_assets/cms/mongodb-logo-rgb-j6w271g1xn.jpg\" width=200\u003e | \u003cimg align='center' src=\"https://cdn.glitch.com/project-avatar/0d184ee3-fd8d-4b94-acf4-b4e686e57375.png\" width=100\u003e | \u003cimg align='center' src=\"https://cdn-images-1.medium.com/max/788/1*0G_7Ab6ZzUMEe-RDJnGjKQ.png\" width=150\u003e | \u003cimg align='center' src=\"https://cdn.auth0.com/website/assets/pages/homepage/img/std_cert/oauth2-360e300bd3.svg\" width=100\u003e | \u003cimg align='left' src=\"https://m.indoorfinders.com/img/btn_google_signin.png\" width=150\u003e |\n\nsample nodejs api with mongodb database and passportjs for authentication using passport-google-oauth20 and jwt tokens.\n\n## Prerequisites\n\n- Obtain credentials from google. [Follow these instructions if you need help](https://youtu.be/9x66l93iEW0?t=1m4s)\n\n- You will also need a mongoDB database to save users. [Instructions for a free mlab database ](https://youtu.be/ySFXduSdpxs)\n\n- Add google api key and mongodb uri in `.env` file.\n\n```bash\ntouch .env\n```\n\n```\nCLIENT_ID=''\nCLIENT_SECRET=''\nMONGO_URI=''\n```\n\n```javascript\nnpm install\n```\n\n```javascript\nnpm start\n```\n\n## How it works\n\nUse [Postman](https://www.getpostman.com/) or any other api testing tool for the following section.\n\nFirst we are going to make a GET request to our google authentication endpoint `/auth/google` which will redirect the user to the google login page. After google successfully authenticates the user it will redirect to our callback endpoint with the user's profile information such as googleId, email etc... now we can save the user in the database or retrieve existing user info and redirect to our auth-success endpoint `/auth-success` where we issue a jwt token.\n\nWe can verify the token validity by making a GET request to the `/verify` endpoint. Don't forget to add the attach the authorization header to the request.\n\n![](https://github.com/gasparrobi/node-google-oauth2-jwt/blob/master/postman.png?raw=true)\n\n## Useful beginner resources\n\n[mongoDB youtube tutorial](https://youtu.be/pWbMrx5rVBE)\n\n[mongoose docs](http://mongoosejs.com/docs/)\n\n[passportjs-google-oauth2-strategy youtube tutorial](https://www.youtube.com/watch?v=sakQbeRjgwg\u0026list=PL4cUxeGkcC9jdm7QX143aMLAqyM-jTZ2x)\n\n[passport-jwt youtube tutorial](https://youtu.be/7nafaH9SddU)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgasparrobi%2Fnode-google-oauth2-jwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgasparrobi%2Fnode-google-oauth2-jwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgasparrobi%2Fnode-google-oauth2-jwt/lists"}