Reputation: 477
Following the auth0 documentation provided here: https://auth0.com/docs/quickstart/spa/angular2/01-login, the app defaults to login page on reload
I've added the localAuthSetup() func in app.component.ts as provided in the documentation. The loggedIn var is always false. I've been debugging the code, but cannot figure out why that is.
localAuthSetup() {
// This should only be called on app initialization
// Set up local authentication streams
const checkAuth$ = this.isAuthenticated$.pipe(
concatMap((loggedIn: boolean) => {
if (loggedIn) {
// If authenticated, get user and set in app
// NOTE: you could pass options here if needed
return this.getUser$();
}
// If not authenticated, return stream that emits 'false'
return of(loggedIn);
})
);
checkAuth$.subscribe((response: { [key: string]: any } | boolean) => {
// If authenticated, response will be user object
// If not authenticated, response will be 'false'
this.loggedIn = !!response;
});
}
on page reload, I expect the user to be fetched, however, I get redirected to the sso login prompt.
Upvotes: 1
Views: 372
Reputation: 477
The issue was with auth0 providing default dev keys when using social identity providers, like Google. That has some limitations. You have to set your own keys, using Google's api.
https://auth0.com/docs/connections/social/devkeys
https://auth0.com/docs/connections/social/google
Upvotes: 1