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:
18
client/app/services/oauth.service.ts
Normal file
18
client/app/services/oauth.service.ts
Normal 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,
|
||||
};
|
||||
Reference in New Issue
Block a user