遵循此处提供的auth0文档:https://auth0.com/docs/quickstart/spa/angular2/01-login, 该应用默认在重新加载时默认登录页面
我已按照文档中的说明在app.component.ts中添加了localAuthSetup()函数。登录的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登录提示符。
答案 0 :(得分:1)
问题出在使用社交身份提供商(例如Google)时,auth0提供默认的开发人员密钥。那有一些限制。您必须使用Google的api设置自己的密钥。
https://auth0.com/docs/connections/social/devkeys
https://auth0.com/docs/connections/social/google