I'm able to signin with google account using aws-amplify library in Reactjs app.
When I logout and try to login again, it doesn't ask me for google username & password. It uses the previous session (somehow) and redirect me back to my react application.
I read different question and applied various solution but none them is working for me.
Solution 1: which doesn't work obviously for google logout.
const logout = () => {
Auth.signout()
}
Solution 2:
const logout = () => {
const requestOptions = {
method: "POST",
'Content-Type': 'application/x-www-form-urlencoded'
};
const url = `https://{domain}.amazoncognito.com/logout?client_id=xxx&response_type=code&scope=xxx&redirect_uri=http://xxx/logout`;
await fetch(url, requestOptions);
}
But for some reason, it thorws CORS issue.
I don't know how and where to resolve CORS issue ? is there anything that I need configure in cognito ?
tried with
method: "GET"
instead ofmethod: "POST"
but same CORS issue.I don't know if this approach is right or wrong. Let me know if there is some other clear way.
Need to know the right way to logout and destroy user's session. So next time when I try to login, it must ask me to enter google username & password.
Update
Solution 3:
const logout = () => {
window.location.href = "https://www.google.com/accounts/Logout?continue=https://appengine.google.com/_ah/logout?continue=http://www.example.com"
}
With above approach, it redirects me to login page of my application but unfortunately when I click on Google Signin
button again, it doesn't show google login screen or doesn't ask me to login again. In other words, it keeps the session alive and doesn't logout for google account.