Created
February 22, 2019 15:12
-
-
Save brianleroux/8bb4463234c220989bc58764b4bb47b0 to your computer and use it in GitHub Desktop.
how to sign in with slack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let tiny = require('tiny-json-http') | |
module.exports = async function slack(code) { | |
// trade the code for an access token | |
let result = await tiny.get({ | |
url: `https://slack.com/api/oauth.access`, | |
data: { | |
client_id: process.env.SLACK_CLIENT_ID, | |
client_secret: process.env.SLACK_CLIENT_SECRET, | |
code, | |
} | |
}) | |
let token = result.body.access_token | |
// get the user account | |
let account = await tiny.get({ | |
url: 'https://slack.com/api/users.identity', | |
data: {token} | |
}) | |
return {token, ...account.body.user} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment