export async function loginToGoogle() {
const { code } = getAuthParams(
(await chrome.identity.launchWebAuthFlow({
interactive: true,
url: `https://accounts.google.com/o/oauth2/v2/auth?${new URLSearchParams({
redirect_uri: chrome.identity.getRedirectURL(import.meta.env.VITE_CHROME_EXT_ID),
client_id: import.meta.env.VITE_GOOGLE_CLIENT_ID,
access_type: "offline",
response_type: "code",
prompt: "consent",
scope: [
"https://www.googleapis.com/auth/userinfo.profile",
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/user.birthday.read",
"https://www.googleapis.com/auth/user.gender.read"
].join(" ")
})}`
})) as string
);
const authData = await getGoogleAuthData({ code });
return getGoogleProfile(authData);
}
OAuth 2.0: authenticate users with Google | Chrome Extensions | Chrome for Developers
https://developer.chrome.com/docs/extensions/how-to/integrate/oauth