Logout with Expo

Hi there,

I’m facing similar problems to the following unresolved issues:

I’m able to log in to auth0 using the example here: https://github.com/expo/examples/tree/master/with-auth0

I’m using the following to try to log the user out
await WebBrowser.openBrowserAsync(
${myAuth0Domain}/v2/logout?client_id=${auth0ClientId}&returnTo=${redirectUrl},
)

When I do so and check the logs in the auth0 console, I see a successful logout. However, when I hit the /authorize endpoint again, I’m still logged in.

I’ve seen Logout, but it’s not clear from those docs how I can clear the appropriate cookies since I can’t use the react-native SDK with expo.

Any help would be appreciated.

Thanks,
Noah

Noah, have you been able to solve this? I’m seeing the same behavior and am also a bit puzzled. But maybe it’s something we need to take up with the Expo folks?

Thanks

Hannes

Hi @hannes.hesse ,

This has shifted down my list of priorities lately, and I haven’t figured out a solution yet. I was doing some digging during the holiday break, and I think the solution lies somewhere in the expo AuthSession docs. Specifically, my next shot would be to mess around with some of the methods exposed there, specifically AuthSession.revokeAsync(). I still haven’t attempted this solution, but I think the issue has to do with cookies being passed back from the expo WebBrowser that AuthSession is built on top of.

So, using WebBrowser.openAuthSessionAsync instead of openBrowserAsync works for me – though I’m not clear why.

2 Likes

I am facing the same issue - WebBrowser.openAuthSession with the URL as the logout endpoint kills the session, but shows all the messaging as if you are getting logged in. If anyone has seen a better solution for sign out with this browser flow and expo-auth-session, I would love to hear it.

2 Likes

Thank you so much! It solved my problem, logout from Keycloak:
Login: useAuthRequest…
Logout:
let logoutUrl = http://192.168.0.10:8182/realms/SpringBootKeycloak/protocol/openid-connect/logout;
await WebBrowser.openAuthSessionAsync(logoutUrl);