passport-slack icon indicating copy to clipboard operation
passport-slack copied to clipboard

Doesn't Return Bot access Token

Open Fyrebox opened this issue 9 years ago • 4 comments
trafficstars

As per the slack API documentation (https://api.slack.com/docs/oauth see section "Bot user access tokens"), when a bot created, the JSON payload should return the access token along with the bot user access token. However, we only get the accessToken. Is there a way to get both tokens by adding a parameter to the Oauth flow?

Fyrebox avatar Apr 06 '16 09:04 Fyrebox

Any update on this?

franz-josef-kaiser avatar May 04 '16 12:05 franz-josef-kaiser

Nope, I gave trying to make it work. I decided to use the Slack button to start the OAuth flow and get the tokens with a simple get request

Fyrebox avatar May 04 '16 17:05 Fyrebox

I would love this as well! I'm confused about how bot tokens fit into the oauth flow.

amackera avatar Sep 02 '16 00:09 amackera

Include bot in the scope option, and also add a params argument to the verify callback:

passport.use(new SlackStrategy({
  clientID: process.env.SLACK_CLIENT_ID,
  clientSecret: process.env.SLACK_CLIENT_SECRET,
  scope: 'bot users:read',
}, (accessToken, refreshToken, params, profile, done) => {
   console.log(params.bot); // Should have `bot_user_id` and `bot_access_token`
}));

It's probably documented elsewhere --- took me forever to figure that out, sadly.

amackera avatar Sep 02 '16 03:09 amackera