5

我不断从 Windows Live 收到此错误

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

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

在我的 <head> 元素中

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

在我的 <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"]
});

登录按钮是

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

听者

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);
            });

});
4

1 回答 1

4

事实证明, redirect_uri 必须是完全http://www.yourdomain.com而不是http://yourdomain.com. 因此,如果用户输入http://yourdomain.com,则将显示此错误,但如果用户输入,则http://www.yourdomain.com脚本有效。

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

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

于 2012-09-27T15:59:20.100 回答