Hi there!
SDK: auth0-js
Version: 9.7.3
Platform: in-browser, latest Chrome
I’m just getting started, the code had not previously worked for me
Here is the HAR file:
localhost.har (21.4 KB)
Having trouble calling the logout endpoint. In some cases, when I call webAuth.logout, it does not log out, but instead redirects to my login callback URL. My app then logs the user back in (i.e. writes token to local storage), which results in a continuous cycle of not being able to logout at all. In other cases, it works as expected. I noticed that it brakes when authentication method is set to Database, and works as expected when it is Google Oauth.
I did not see an obvious difference between requests made when it works and when it doesn’t, but I noticed that in both cases it ignores returnTo parameter that I pass to webAuth.logout.
Here is my client side code:
export default class Auth {
static domain = ;
static clientId = ;
constructor() {
this.login = this.login.bind(this);
this.logout = this.logout.bind(this);
this.handleAuthentication = this.handleAuthentication.bind(this);
}
auth0 = new auth0.WebAuth({
domain: Auth.domain,
clientID: Auth.clientId,
responseType: ‘id_token’,
scope: ‘openid profile email’
});
handleAuthentication(callback) {
this.auth0.parseHash((err, authResult) => {
if (authResult && authResult.idToken) {
Session.setSession(authResult);
callback();
} else if (err) {
throw new Error(err);
}
});
}
login() {
this.auth0.authorize({
redirectUri: http://localhost:3001${AUTH_LOGIN_CALLBACK_ROUTE}
});
}
signup() {
this.auth0.authorize({
redirectUri: http://localhost:3001${AUTH_SIGNUP_CALLBACK_ROUTE}
});
}
logout() {
Session.clearSession();
this.auth0.logout({
returnTo: 'http://localhost:3000/',
clientId: Auth.clientId,
});
}
}
Thanks for your help!