1
0
mirror of https://github.com/mgerb/go-discord-bot synced 2026-01-11 09:32:50 +00:00

fetch client id from server for oauth

This commit is contained in:
2018-04-15 16:16:24 -05:00
parent f13b177a93
commit 5d5717effe
5 changed files with 60 additions and 15 deletions

View File

@@ -0,0 +1,18 @@
import { axios } from './axios.service';
const redirectUrl = window.location.origin + '/oauth';
const getClientID = async (): Promise<string> => {
const res = await axios.get('/api/config/client_id');
return res.data['id'];
};
const getOauthUrl = async (): Promise<string> => {
const clientID = await getClientID();
return `https://discordapp.com/api/oauth2/authorize?client_id=${clientID}&redirect_uri=${redirectUrl}&response_type=code&scope=email%20identify`;
};
export const OauthService = {
getClientID,
getOauthUrl,
};