{"_id":"@advisr/passport-slack-oauth2","_rev":"2-cfcef15d1ce3ed2f4acbe873194e5de5","name":"@advisr/passport-slack-oauth2","dist-tags":{"latest":"1.2.1"},"versions":{"1.2.1":{"name":"@advisr/passport-slack-oauth2","version":"1.2.1","keywords":["passport","slack","oauth2","auth","authentication","identity"],"author":{"name":"Nathan Maves","email":"nathan.maves@gmail.com"},"_id":"@advisr/passport-slack-oauth2@1.2.1","maintainers":[{"name":"jrohland","email":"jesse.rohland@gmail.com"},{"name":"jonstorer","email":"jonathon.scott.storer@gmail.com"}],"homepage":"https://github.com/nmaves/passport-slack-oauth2#readme","bugs":{"url":"https://github.com/nmaves/passport-slack-oauth2/issues"},"dist":{"shasum":"636ae9265165405703f917e070cc48790c3c664d","tarball":"https://registry.npmjs.org/@advisr/passport-slack-oauth2/-/passport-slack-oauth2-1.2.1.tgz","fileCount":5,"integrity":"sha512-H//QyJh5DyBbhCX3f5uKqxy27+1UE7QRX53eJIVdV/B9WyMaxd/DhVZnjiTZKHk5meJ96VnQpSg/jAjwrGCJFg==","signatures":[{"sig":"MEUCIGDOlOov844GtALLhSuagSGk81lachgPWaz9tIG7KcnMAiEAg9j4WPRAsRUCCkOzJ8zw6oI+sNwbTEfO1cRWiT7N+84=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17964},"main":"./lib/index.js","gitHead":"58d1fce7b1ff566312561ef9ffdc4101088c5793","scripts":{"test":"mocha"},"_npmUser":{"name":"jrohland","email":"jesse.rohland@gmail.com"},"licenses":[{"url":"http://www.opensource.org/licenses/MIT","type":"MIT"}],"repository":{"url":"git+https://github.com/advisr-io/passport-slack-oauth2.git","type":"git"},"_npmVersion":"10.5.2","description":"[Passport](https://github.com/jaredhanson/passport) strategy for authenticating with [Slack](https://slack.com) using the OAuth 2.0 API.","directories":{},"_nodeVersion":"20.13.1","dependencies":{"passport-oauth2":"^1.7.0"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.3.7","mocha":"^10.2.0"},"_npmOperationalInternal":{"tmp":"tmp/passport-slack-oauth2_1.2.1_1733407891132_0.7931921442754684","host":"s3://npm-registry-packages"}}},"time":{"created":"2024-12-05T14:11:31.037Z","modified":"2025-07-17T12:25:04.280Z","1.2.1":"2024-12-05T14:11:31.347Z"},"bugs":{"url":"https://github.com/nmaves/passport-slack-oauth2/issues"},"author":{"name":"Nathan Maves","email":"nathan.maves@gmail.com"},"homepage":"https://github.com/nmaves/passport-slack-oauth2#readme","keywords":["passport","slack","oauth2","auth","authentication","identity"],"repository":{"url":"git+https://github.com/advisr-io/passport-slack-oauth2.git","type":"git"},"description":"[Passport](https://github.com/jaredhanson/passport) strategy for authenticating with [Slack](https://slack.com) using the OAuth 2.0 API.","maintainers":[{"email":"jesse.rohland@gmail.com","name":"jrohland"}],"readme":"# passport-slack-oauth2\n\n[Passport](https://github.com/jaredhanson/passport) strategy for authenticating\nwith [Slack](https://slack.com) using the OAuth 2.0 API.\n\nUpdated to support Sign in with Slack by default.\n\n[![Sign in with Slack](https://a.slack-edge.com/accd8/img/sign_in_with_slack.png)](https://api.slack.com/docs/sign-in-with-slack#identify_users_and_their_teams)\n\n## Install\n```shell\n$ npm install passport-slack-oauth2\n```\n\n## Sample Profile\n```json\n{\n    \"provider\": \"slack\",\n    \"id\": \"U123XXXXX\",\n    \"displayName\": \"John Agan\",\n    \"user\": {\n        \"name\": \"John Agan\",\n        \"id\": \"U123XXXXX\",\n        \"email\": \"johnagan@testing.com\",\n        \"image_24\": \"https://secure.gravatar.com/avatar/123abcd123bc12b3c.jpg?s=24&d=https%3A%2F%2Fa.slack-edge.com%2F66f9%2Fimg%2Favatars%2Fava_0000-24.png\",\n        \"image_32\": \"https://secure.gravatar.com/avatar/123abcd123bc12b3c.jpg?s=32&d=https%3A%2F%2Fa.slack-edge.com%2F66f9%2Fimg%2Favatars%2Fava_0000-32.png\",\n        \"image_48\": \"https://secure.gravatar.com/avatar/123abcd123bc12b3c.jpg?s=48&d=https%3A%2F%2Fa.slack-edge.com%2F66f9%2Fimg%2Favatars%2Fava_0000-48.png\",\n        \"image_72\": \"https://secure.gravatar.com/avatar/123abcd123bc12b3c.jpg?s=72&d=https%3A%2F%2Fa.slack-edge.com%2F66f9%2Fimg%2Favatars%2Fava_0000-72.png\",\n        \"image_192\": \"https://secure.gravatar.com/avatar/123abcd123bc12b3c.jpg?s=192&d=https%3A%2F%2Fa.slack-edge.com%2F7fa9%2Fimg%2Favatars%2Fava_0000-192.png\",\n        \"image_512\": \"https://secure.gravatar.com/avatar/123abcd123bc12b3c.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F7fa9%2Fimg%2Favatars%2Fava_0000-512.png\"\n        \"image_1024\": \"https://secure.gravatar.com/avatar/123abcd123bc12b3c.jpg?s=512&d=https%3A%2F%2Fa.slack-edge.com%2F7fa9%2Fimg%2Favatars%2Fava_0000-1024.png\"\n    },\n    \"team\": {\n        \"id\": \"T123XXXX\",\n        \"name\": \"My Awesome Team\",\n        \"domain\": \"my-awesome-team\",\n        \"image_34\": \"https://a.slack-edge.com/0000/img/avatars-teams/ava_0000-00.png\",\n        \"image_44\": \"https://a.slack-edge.com/00a0/img/avatars-teams/ava_0000-00.png\",\n        \"image_68\": \"https://a.slack-edge.com/00a0/img/avatars-teams/ava_0000-00.png\",\n        \"image_88\": \"https://a.slack-edge.com/00a0/img/avatars-teams/ava_0000-00.png\",\n        \"image_102\": \"https://a.slack-edge.com/00a0/img/avatars-teams/ava_0000-000.png\",\n        \"image_132\": \"https://a.slack-edge.com/00a0/img/avatars-teams/ava_0000-000.png\",\n        \"image_230\": \"https://a.slack-edge.com/0a0a0/img/avatars-teams/ava_0000-000.png\",\n        \"image_default\": true\n    }\n}\n```\n\n## Usage\n\n### Configure Strategy\n\nThe Slack authentication strategy authenticates users using a Slack\naccount and OAuth 2.0 tokens.  The strategy requires a `verify` callback, which\naccepts these credentials and calls `done` providing a user, as well as\n`options` specifying a client ID, client secret, and callback URL.\n\n```js\npassport.use(new SlackStrategy({\n    clientID: CLIENT_ID,\n    clientSecret: CLIENT_SECRET,\n    skipUserProfile: false, // default\n    scope: ['users:read'] // default, bot token scope\n    scope: ['identity.basic', 'identity.email', 'identity.avatar', 'identity.team'] // default, user token scope\n  },\n  (accessToken, refreshToken, profile, done) => {\n    // optionally persist user data into a database\n    done(null, profile);\n  }\n));\n```\n\nIn order to access multiple tokens within the OAuth2 Token Response, provide a verify callback with 5 parameters.\n\n```js\npassport.use(new SlackStrategy({\n    clientID: CLIENT_ID,\n    clientSecret: CLIENT_SECRET,\n    skipUserProfile: false, // default\n    scope: ['users:read'] // bot token scope, default\n    scope: ['identity.basic', 'identity.email', 'identity.avatar', 'identity.team'] // user token scope, default\n  },\n  (accessToken, refreshToken, params, profile, done) => { // 5 parameters\n    // optionally persist user data into a database\n    done(null, profile);\n  }\n));\n```\n\n## Sample Parsed Token Responses\n\n### User & Bot\n```json\n{\n    \"id\": \"U123XXXXX\",\n    \"scope\": \"user-scope-1,user-scope-2\",\n    \"token_type\": \"user\",\n    \"access_token\": \"user-access-token\",\n    \"refresh_token\": \"user-refresh-token\",\n    \"authed_user\": {\n        \"id\": \"U123XXXXX\",\n        \"scope\": \"user-scope-1,user-scope-2\",\n        \"access_token\": \"user-access-token\",\n        \"token_type\": \"user\"\n    },\n    \"authed_bot\": {\n        \"id\": \"U987XXXXX\",\n        \"scope\": \"bot-scope-1,bot-scope-2\",\n        \"token_type\": \"bot\",\n        \"access_token\": \"bot-access-token\",\n        \"refresh_token\": \"bot-refresh-token\"\n    }\n}\n```\n\n### User only\n```json\n{\n    \"id\": \"U123XXXXX\",\n    \"scope\": \"user-scope-1,user-scope-2\",\n    \"token_type\": \"user\",\n    \"access_token\": \"user-access-token\",\n    \"refresh_token\": \"user-refresh-token\",\n    \"authed_user\": {\n        \"id\": \"U123XXXXX\",\n        \"scope\": \"user-scope-1,user-scope-2\",\n        \"access_token\": \"user-access-token\",\n        \"token_type\": \"user\"\n    },\n    \"authed_bot\": {\n    }\n}\n```\n\n### Bot only\n```json\n{\n    \"id\": \"U987XXXXX\",\n    \"scope\": \"bot-scope-1,bot-scope-2\",\n    \"token_type\": \"bot\",\n    \"access_token\": \"bot-access-token\",\n    \"refresh_token\": \"bot-refresh-token\",\n    \"authed_user\": {\n        \"id\": \"U123XXXXX\",\n    },\n    \"authed_bot\": {\n        \"id\": \"U987XXXXX\",\n        \"scope\": \"bot-scope-1,bot-scope-2\",\n        \"token_type\": \"bot\",\n        \"access_token\": \"bot-access-token\",\n        \"refresh_token\": \"bot-refresh-token\",\n    }\n}\n```\n\n### Authenticate Requests\n\nUse `passport.authenticate()` (or `passport.authorize()` if you want to authenticate with Slack and **NOT** affect `req.user` and user session), specifying the `'slack'` strategy, to\nauthenticate requests.\n\nFor example, as route middleware in an [Express](http://expressjs.com/)\napplication:\n\n```js\napp.get('/auth/slack', passport.authorize('slack'));\n\napp.get('/auth/slack/callback',\n  passport.authenticate('slack', { failureRedirect: '/login' }),\n  (req, res) => res.redirect('/') // Successful authentication, redirect home.\n);\n```\n\n### Custom User Scopes\nBy default passport-slack strategy will try to retrieve [all user identity](https://api.slack.com/methods/users.identity) from Slack using the default scopes of `identity.basic`, `identity.email`, `identity.avatar`, and `identity.team`. To override these, set the `user_scope` parameter to an array of [user scopes](https://api.slack.com/scopes?filter=user).\n\n```js\npassport.use(new SlackStrategy({\n  clientID: CLIENT_ID,\n  clientSecret: CLIENT_SECRET,\n  scope: [],                      // no (bot) 'scope' defined, no bot tokens issued\n  user_scope: [\n    \"identity.basic\",\n    \"channels:read\",\n    \"chat:write:user\"\n  ]\n}, () => { });\n```\n\n### Custom Bot Scopes\nBy default passport-slack strategy will try to retrieve [bot info](https://api.slack.com/methods/users.info) from Slack using the default scopes of `users:read`. To override these, set the `scope` parameter to an array of [bot scopes](https://api.slack.com/scopes?filter=granular_bot).\n\n```js\npassport.use(new SlackStrategy({\n  clientID: CLIENT_ID,\n  clientSecret: CLIENT_SECRET,\n  scope: [\n    \"users:read\"\n  ],\n  user_scope: []                  // no 'user_scope' defined, no user tokens issued\n}, () => { });\n```\n\n### Ignore Profile Info\nIf you just need an access token and not user profile data, you can avoid getting profile info by setting `skipUserProfile` to true.\n```js\npassport.use(new SlackStrategy({\n\tclientID: CLIENT_ID,\n\tclientSecret: CLIENT_SECRET,\n\tscope: ['incoming-webhook'],\n\tuser_scope: ['incoming-webhook'],\n\tskipUserProfile: true\n}, () => { });\n```\n\n## License\n\n[The MIT License](http://opensource.org/licenses/MIT)","readmeFilename":"README.md"}