0

我正在尝试在我的 Angular2 应用程序中使用锁(版本 10.11.0)实现 Auth0。如果我在 Auth0 客户端的 Allowed Callback URLs 设置中列出所有可能的路由,则 Auth0 有效。似乎 Auth0 从用户决定登录时碰巧在的任何 URL 中获取回调 URL。这不是一种可扩展的方法。你如何解决这个问题?

我尝试在身份验证选项中输入 redirectUrl 值。这让我更进一步,因为应用程序确实重定向到提供的 URL,但是,Auth0 锁的身份验证回调永远不会触发,因此我无法检索经过身份验证的用户的配置文件。

所以,我被困住了。看来我唯一的做法是在 Auth0 客户端的 Allowed Callback URLs 设置中列出所有可能的路由,并祈祷营销人员不要想出更多路由。

这是我的代码:

        let options =
        {
            auth:
            {
                //redirectUrl: 'http://localhost:4200',
                //redirect: true,
                responseType: 'token',
                params:
                {
                    scope: 'openid user_id name nickname email picture'
                }
            }
        };

        this.lock = new Auth0Lock('xxx', 'yyy', options);

        this.lock.on("authenticated", (authResult) =>
        {
            console.log('@@@@  AUTH RESULTS:', authResult); 

            localStorage.setItem('id_token', authResult.idToken);

            this.lock.getProfile(authResult.idToken, (error, profile) => 
            {
                if (error) 
                {
                    return;
                }

                console.log('@@@@  AUTHENTICATED USER PROFILE:', profile);

            });
        }

关于如何使 Auth0 工作的任何想法,因此您不必在决定进行身份验证之前列出用户可以使用的所有可能路线?

4

0 回答 0