This is how I get the user’s consent:
const { code } = getAuthParams(
await chrome.identity.launchWebAuthFlow({
interactive: true,
url: `https://accounts.google.com/o/oauth2/v2/auth?${new URLSearchParams({
redirect_uri: REDIRECT_URI,
client_id: 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",
"https://www.googleapis.com/auth/user.addresses.read"
].join(" ")
})}`
})
);
const authData = await getGoogleAuthData({ code });
So far, I attempted to get the street address with the following:
const json = await (await fetch("https://people.googleapis.com/v1/people/me?personFields=birthdays,genders,addresses", {
headers: {
Authorization: `Bearer ${authData.access_token}`
}
})).json();
However, the JSON response only contains birthdays
and genders