This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
outline/shared/utils/routeHelpers.js
2017-11-21 23:51:31 -08:00

27 lines
597 B
JavaScript

// @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}`;
}