Working direct install flow
This commit is contained in:
26
shared/utils/routeHelpers.js
Normal file
26
shared/utils/routeHelpers.js
Normal file
@ -0,0 +1,26 @@
|
||||
// @flow
|
||||
|
||||
export function slackAuth(
|
||||
state: string,
|
||||
scopes: string[] = [
|
||||
'identity.email',
|
||||
'identity.basic',
|
||||
'identity.avatar',
|
||||
'identity.team',
|
||||
],
|
||||
redirectUri: string = `${process.env.URL}/auth/slack`
|
||||
): string {
|
||||
const baseUrl = 'https://slack.com/oauth/authorize';
|
||||
const params = {
|
||||
client_id: process.env.SLACK_KEY,
|
||||
scope: scopes ? scopes.join(' ') : '',
|
||||
redirect_uri: redirectUri,
|
||||
state,
|
||||
};
|
||||
|
||||
const urlParams = Object.keys(params)
|
||||
.map(key => `${key}=${encodeURIComponent(params[key])}`)
|
||||
.join('&');
|
||||
|
||||
return `${baseUrl}?${urlParams}`;
|
||||
}
|
Reference in New Issue
Block a user