Getting “Callback URL mismatch” with Auth0

耗尽温柔 提交于 2019-12-05 17:42:35

I was experiencing this same issue and solved it with Shrek's suggestion above (not the same Schreck as me). However, I had to use window.top.location.origin instead of window.top.location.hostname. For me, window.top.location.origin equates to the Allowed Callback URLs values in my client settings in Auth0.

Here's my code:

    let stateOptions =
    {
        "auth0_authorize": this.authNonce,
        "return_url": router.url
    };

    let options =
        {
            closable: false,
            languageDictionary:
            {
                emailInputPlaceholder: "something@youremail.com",
                title: "Log me in"
            },
            auth:
            {
                redirectUrl: window.top.location.origin,
                redirect: true,
                responseType: 'token',
                params:
                {
                    state: btoa(JSON.stringify(stateOptions)),
                    scope: 'openid user_id name nickname email picture'
                }
            }
        };

    this.lock = new Auth0Lock('[your-auth0-clientid]', '[your-auth0-domain]', options);

this problem also confused me for a long time. Finally, I figured it out in a configuration page in Auth0.

It is very funny to do this. I do not know the reason why Auth0 use this to save the callback url. In fact, we always set the RedirectURL in the code. This is totally different from authorization in google. Anyway, the problem is solved.

By the way I google for this error at the very beginning but I found this solution in Auth0 configuration page. There is a video tutorial on the top.

I Hope this helped.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!