{"id":19298900,"url":"https://github.com/smth-for/passport-google-access-token","last_synced_at":"2025-04-22T09:32:44.613Z","repository":{"id":42789363,"uuid":"273536838","full_name":"smth-for/passport-google-access-token","owner":"smth-for","description":null,"archived":false,"fork":false,"pushed_at":"2023-07-18T22:35:16.000Z","size":699,"stargazers_count":7,"open_issues_count":10,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-01T22:12:03.360Z","etag":null,"topics":["google","passport","passport-google","passportjs"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smth-for.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-19T16:15:23.000Z","updated_at":"2023-07-27T09:26:40.000Z","dependencies_parsed_at":"2024-06-21T14:22:33.298Z","dependency_job_id":null,"html_url":"https://github.com/smth-for/passport-google-access-token","commit_stats":{"total_commits":15,"total_committers":2,"mean_commits":7.5,"dds":"0.19999999999999996","last_synced_commit":"c03796da9a5a4acfa1f670ee63d0203ee64d4b81"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smth-for%2Fpassport-google-access-token","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smth-for%2Fpassport-google-access-token/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smth-for%2Fpassport-google-access-token/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smth-for%2Fpassport-google-access-token/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smth-for","download_url":"https://codeload.github.com/smth-for/passport-google-access-token/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249474528,"owners_count":21278511,"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":["google","passport","passport-google","passportjs"],"created_at":"2024-11-09T23:09:29.173Z","updated_at":"2025-04-22T09:32:44.320Z","avatar_url":"https://github.com/smth-for.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Banner](static/passportGoogleAccessToken.jpg)](https://smth.it)\n\n[![npm version](https://img.shields.io/npm/v/@smth-for/passport-google-access-token.svg)](https://www.npmjs.com/package/@smth-for/passport-google-access-token)\n[![Dependency Status](https://david-dm.org/smth-for/passport-google-access-token.svg)](https://david-dm.org/smth-for/passport-google-access-token)\n[![devDependency Status](https://david-dm.org/smth-for/passport-google-access-token/dev-status.svg)](https://david-dm.org/smth-for/passport-google-access-token#info=devDependencies)\n[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/smth-for/passport-google-access-token/issues)\n[![Downloads](https://img.shields.io/npm/dm/@smth-for/passport-google-access-token.svg)](https://img.shields.io/npm/dm/@smth-for/passport-google-access-token.svg)\n[![HitCount](http://hits.dwyl.com/smth-for/passport-google-access-token.svg)](http://hits.dwyl.com/smth-for/passport-google-access-token)\n\n# passport-google-access-token\n\n[Passport](http://passportjs.org/) strategy for authenticating with [Google](http://www.google.com/) access tokens using the OAuth 2.0 API.\n\nThis module lets you authenticate using google in your Node.js applications.\nBy plugging into Passport, google authentication can be easily and unobtrusively integrated into any application or framework that supports [Express](http://expressjs.com/).\n\n## Installation\n\n```shell\nnpm install @smth-for/passport-google-access-token\n```\n\n## Usage\n\n### Configure Strategy\n\nThe google authentication strategy authenticates users using a google account and OAuth 2.0 tokens.\nThe strategy requires a `verify` callback, which accepts these credentials and calls `done` providing a user, as well as\n`options` specifying a app ID and app secret.\n\n```js\nconst GoogleTokenStrategy = require('passport-google-token');\n\npassport.use(new GoogleTokenStrategy({\n    clientID: google_APP_ID,\n    clientSecret: google_APP_SECRET,\n  }, function(accessToken, refreshToken, profile, done) {\n    User.findOrCreate({googleId: profile.id}, function (error, user) {\n      return done(error, user);\n    });\n  }\n));\n```\n\n### Authenticate Requests\n\nUse `passport.authenticate()`, specifying the `'google-token'` strategy, to authenticate requests.\n\n```js\napp.post('/auth/google/token',\n  passport.authenticate('google-token'),\n  function (req, res) {\n    // do something with req.user\n    res.send(req.user? 200 : 401);\n  }\n);\n```\n\nOr using Sails framework:\n\n```javascript\n// api/controllers/AuthController.js\nmodule.exports = {\n  google: function(req, res) {\n    passport.authenticate('google-token', function(error, user, info) {\n      // do stuff with user\n      res.ok();\n    })(req, res);\n  }\n};\n```\n\n### Client Requests\n\nClients can send requests to routes that use passport-google-token authentication using query params, body, or HTTP headers.\nClients will need to transmit the `access_token` and optionally the `refresh_token` that are received from google after login.\n\n#### Sending access_token as a Query parameter\n\n```shell\nGET /auth/google/token?access_token=\u003cTOKEN_HERE\u003e\n```\n\n#### Sending access token as an HTTP header\n\nClients can choose to send the access token using the Oauth2 Bearer token (RFC 6750) compliant format.\n\n```shell\nGET /resource HTTP/1.1\nHost: server.example.com\nAuthorization: Bearer base64_access_token_string\n```\n\nOptionally a client can send via a custom (default access_token) header.\n\n```shell\nGET /resource HTTP/1.1\nHost: server.example.com\naccess_token: base64_access_token_string\n```\n\n#### Sending access token as an HTTP body\n\nClients can transmit the access token via the body\n\n```shell\nPOST /resource HTTP/1.1\nHost: server.example.com\n\naccess_token=base64_access_token_string\n```\n## Join SMTH Community\n![Discord Banner 2](https://discordapp.com/api/guilds/748546400631128204/widget.png?style=banner2)\n\n[INVITATION LINK](https://discord.gg/H6NkzZy)\n\n## Code of Conduct\n[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md)\n\n## License\n\n[MIT License](LICENCE)\n\n## Special Thanks\n\n- [Nicholas Penree](https://github.com/drudge)\n- [Jared Hanson](https://github.com/jaredhanson)\n- [Eugene Obrezkov](https://github.com/ghaiklor)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmth-for%2Fpassport-google-access-token","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmth-for%2Fpassport-google-access-token","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmth-for%2Fpassport-google-access-token/lists"}