
I have a web app in reactjs that uses the Google login that is integrated into Appwrite for user login. I use createOAuth2Token()
to login to their account. And I use createSession()
to create a session within the Appwrite environment. To logout, I use deleteSession()
. This approach of mine, however, only deletes the user's in process session within the Appwrite environment. It does not logout the user from their google account. I know this, because after clicking 'logout, when the user tries to log back in, they are immediately signed in without being prompted to enter their Google credentials again.
I logged the details of the session, and I saw that providerAccessToken
is an empty string. Since providerAccessToken
is an empty string for Googe OAuth2 logins, I assumend that the session $id
can replace it. However, it did not help. Google returns Bad Request and does not logout the user from Google.
export const deleteUserSession = async () => {
const currentSession = await account.getSession('current');
const accessToken = currentSession.$id;
console.log('currentSession', currentSession);
console.log('accessToken', accessToken);
try {
if (currentSession && accessToken) {
await account.deleteSession(currentSession.$id);
console.log('Session deleted successfully');
await fetch('https://accounts.google.com/o/oauth2/revoke?token=' + accessToken, {
method: 'GET',
mode: 'no-cors',
});
console.log('LOGGED OUT SUCCESSFULLY.');
}
console.log('REDIRECTING TO /');
} catch (error) {
console.error('Error deleting the session:', error);
}
}
Recommended threads
- Need help setting up this error is showi...
You can't sign in to this app because it doesn't comply with Google's OAuth 2.0 policy. If you're the app developer, register the redirect URI in the Google Cl...
- Appwrite stopped working, I can't authen...
I'm having an issue with Appwrite. It was working fine just a while ago, but suddenly it stopped working for me and can't authenticate accounts. I even went bac...
- Set succes/failure url in console
Hi guys, I want to set up a succes and failure url for my OAuth2 provider Google. But I don't see any options for this? Is it not possible to do so? Beside th...
