mirror of
https://github.com/open-webui/open-webui
synced 2025-05-11 09:04:45 +00:00
fix: Improve Google OAuth token retrieval with proper Promise handling
This commit is contained in:
parent
c3d631ca98
commit
ba19ff8ace
@ -59,16 +59,24 @@ export const loadGoogleAuthApi = () => {
|
||||
|
||||
export const getAuthToken = async () => {
|
||||
if (!oauthToken) {
|
||||
const tokenClient = google.accounts.oauth2.initTokenClient({
|
||||
client_id: CLIENT_ID,
|
||||
scope: SCOPE.join(' '),
|
||||
callback: (response: any) => {
|
||||
if (response.access_token) {
|
||||
oauthToken = response.access_token;
|
||||
return new Promise((resolve, reject) => {
|
||||
const tokenClient = google.accounts.oauth2.initTokenClient({
|
||||
client_id: CLIENT_ID,
|
||||
scope: SCOPE.join(' '),
|
||||
callback: (response: any) => {
|
||||
if (response.access_token) {
|
||||
oauthToken = response.access_token;
|
||||
resolve(oauthToken);
|
||||
} else {
|
||||
reject(new Error('Failed to get access token'));
|
||||
}
|
||||
},
|
||||
error_callback: (error: any) => {
|
||||
reject(new Error(error.message || 'OAuth error occurred'));
|
||||
}
|
||||
},
|
||||
});
|
||||
tokenClient.requestAccessToken();
|
||||
});
|
||||
await tokenClient.requestAccessToken();
|
||||
}
|
||||
return oauthToken;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user