javascript 为输入参数“redirect_uri”提供的值无效

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12619532/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 16:41:11  来源:igfitidea点击:

The provided value for the input parameter 'redirect_uri' is not valid

javascriptphpbbphpbb3windows-live

提问by Damien Keitel

I keep receiving this error from windows live

我不断从 windows live 收到这个错误

The provided value for the input parameter 'redirect_uri' is not valid. The expected value is 'https://login.live.com/oauth20_desktop.srf' or a URL which matches the redirect

为输入参数“redirect_uri”提供的值无效。预期值为“https://login.live.com/oauth20_desktop.srf”或与重定向匹配的 URL

Why do I keep receiving this error. I have the domain set in the windows live developer app

为什么我一直收到这个错误。我在 windows live 开发者应用程序中设置了域

in the <head> element I have

在 <head> 元素中我有

<script src="//js.live.net/v5.0/wl.js"></script>

just below the <body> element I have

就在我拥有的 <body> 元素下方

  WL.init({
    client_id: '{S_AL_WL_CLIENT_ID}', //{S_AL_WL_CLIENT_ID} = phpbb template variable for client_id
    redirect_uri: '{AL_BOARD_URL}', //{AL_BOARD_URL} = phpbb template variable for the  urlencoded domain name
    response_type: 'token',
    scope: ["wl.signin", "wl.basic", "wl.birthday", "wl.emails", "wl.work_profile", "wl.postal_addresses"]
});

the login button is

登录按钮是

    <div id="login">
        <a href="#"><img src="images/windows_live_connect.png" alt="Windows Live" /></a> 
    </div>

the listener

听者

jQuery('#login a').click(function(e) 
{
    e.preventDefault();
            WL.login({
                scope: ["wl.signin", "wl.basic", "wl.birthday", "wl.emails", "wl.work_profile", "wl.postal_addresses"]
            }).then(function (response) 
            {
                //do something with stuff here. You know brainy type ajaxy stuff to auth a user
            },
            function (responseFailed) 
            {
                console.log("Error signing in: " + responseFailed.error_description);
            });

});

采纳答案by Damien Keitel

The problem turned out that windows-liveredirect_uri has to be exactly http://www.yourdomain.comand not http://yourdomain.com. So if a user inputs http://yourdomain.comthen this error will show but if a user has http://www.yourdomain.comthen the script works.

问题原来是windows-liveredirect_uri 必须完全是http://www.yourdomain.com而不是http://yourdomain.com. 因此,如果用户输入,http://yourdomain.com则会显示此错误,但如果用户输入,则http://www.yourdomain.com脚本会起作用。

I think I have been very spoilt with the Facebook Api.

我想我已经被 Facebook Api 宠坏了。

So in the end I just made a regex to match against any url using the login button and force it to be www with .htaccess.

所以最后我只是做了一个正则表达式来匹配任何使用登录按钮的 url,并强制它是 www 和 .htaccess。