Auth0 在重新加载时注销我,而不是获取用户
Auth0 logging me out on reload, instead of fetching the user
遵循此处提供的 auth0 文档:https://auth0.com/docs/quickstart/spa/angular2/01-login,
该应用程序默认为重新加载时的登录页面
我已按照文档中的说明在 app.component.ts 中添加了 localAuthSetup() 函数。 loggedIn var 始终为 false。我一直在调试代码,但无法弄清楚为什么会这样。
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;
});
}
在页面重新加载时,我希望获取用户,但是,我被重定向到 sso 登录提示。
问题在于 auth0 在使用社交身份提供商时提供默认开发密钥,例如 Google。这有一些限制。您必须使用 Google 的 api 设置自己的密钥。
https://auth0.com/docs/connections/social/devkeys
https://auth0.com/docs/connections/social/google
遵循此处提供的 auth0 文档:https://auth0.com/docs/quickstart/spa/angular2/01-login, 该应用程序默认为重新加载时的登录页面
我已按照文档中的说明在 app.component.ts 中添加了 localAuthSetup() 函数。 loggedIn var 始终为 false。我一直在调试代码,但无法弄清楚为什么会这样。
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;
});
}
在页面重新加载时,我希望获取用户,但是,我被重定向到 sso 登录提示。
问题在于 auth0 在使用社交身份提供商时提供默认开发密钥,例如 Google。这有一些限制。您必须使用 Google 的 api 设置自己的密钥。
https://auth0.com/docs/connections/social/devkeys
https://auth0.com/docs/connections/social/google