I’m getting an error with GSI saying
The given origin is not allowed for the given client ID
However it’s only happening on Android. I have no idea why this is. Any ideas?
In Chrome on Windows and Mac it works fine. I’ve searched all over Google and read the documentation carefully through to find a solution for this, but so far I’m stuck.
async function initClient() {
await google.accounts.id.initialize({
auto_select: true,
referrerPolicy: {
policy: 'strict-origin-when-cross-origin'
}
client_id: CLIENT_ID,
callback: creds => initTokenClient(creds)
});
google.accounts.id.prompt();
google.accounts.id.renderButton(
document.getElementById("buttonDiv"), {
locale: "en"
}
);
}
function initTokenClient(creds) {
client = google.accounts.oauth2.initTokenClient({
client_id: CLIENT_ID,
referrerPolicy: {
policy: 'strict-origin-when-cross-origin'
}
scope: 'https://www.googleapis.com/auth/calendar.readonly
https://www.googleapis.com/auth/gmail.readonly https://www.googleapis.com/auth/admin.directory.user',
callback: (res) => checkAuth(res)
});
getToken();
}
function checkAuth(res) {
if (res !== undefined) {
access_token = res.access_token;
listUpcomingEvents();
} else {
console.log("Could not auth");
}
}
function getToken() {
client.requestAccessToken();
}
function revokeToken() {
google.accounts.oauth2.revoke(access_token, () => {
console.log('access token revoked')
});
}