mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-25 05:54:25 -04:00
(discord) fix eagerly refreshing access token
This commit is contained in:
parent
ccba73890f
commit
5ee23fb01d
@ -62,7 +62,7 @@ const getAccessToken = async (userId: string) => {
|
||||
if (tokenSet === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
if (Date.now() > tokenSet.expires_in) {
|
||||
if (Date.now() > tokenSet.expires_at!) {
|
||||
const token: TokenSet = await fetch(`${BASE_DISCORD_URI}/oauth2/token`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
@ -74,6 +74,7 @@ const getAccessToken = async (userId: string) => {
|
||||
}).then((res) => res.json());
|
||||
token.expires_at = Date.now() + tokenSet.expires_in * 1e3;
|
||||
store.set(userId, token);
|
||||
return token.access_token;
|
||||
}
|
||||
return tokenSet.access_token;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user