微软oAuth似乎并没有起作用

时间:2014-06-25 19:46:25

标签: php oauth

我正在尝试将microsoft登录添加到我正在开发的应用程序中,但我反复收到这个我无法理解的错误。

enter image description here

网址为: -

https://login.live.com/err.srf?lc=1033#error=invalid_request&error_description=The%20provided%20value%20for%20the%20input%20parameter%20'redirect_uri'%20is%20not%20valid.%20The%20expected%20value%20is%20'https://login.live.com/oauth20_desktop.srf'%20or%20a%20URL%20which%20matches%20the%20redirect%20URI%20registered%20for%20this%20client%20application.&state=1403724714-562028

代码

<?php
    require('lib/http.php');
    require('lib/oauth_client.php');

    $client = new oauth_client_class;
    $client->server = 'Microsoft';
    //$client->redirect_uri = 'http://'.$_SERVER['HTTP_HOST'].
        //dirname(strtok($_SERVER['REQUEST_URI'],'?')).'/login.php';
    $client->redirect_uri='http://novostack.com/mscr/login.php';
    $client->client_id = 'clietidhere'; $application_line = __LINE__;
    $client->client_secret = 'secrethere';

    if(strlen($client->client_id) == 0
    || strlen($client->client_secret) == 0)
        die('Please go to Microsoft Live Connect Developer Center page '.
            'https://manage.dev.live.com/AddApplication.aspx and create a new'.
            'application, and in the line '.$application_line.
            ' set the client_id to Client ID and client_secret with Client secret. '.
            'The callback URL must be '.$client->redirect_uri.' but make sure '.
            'the domain is valid and can be resolved by a public DNS.');

    /* API permissions
     */
    $client->scope = 'wl.basic wl.emails wl.birthday';
    if(($success = $client->Initialize()))
    {
        if(($success = $client->Process()))
        {
            if(strlen($client->authorization_error))
            {
                $client->error = $client->authorization_error;
                $success = false;
            }
            elseif(strlen($client->access_token))
            {
                $success = $client->CallAPI(
                    'https://apis.live.net/v5.0/me',
                    'GET', array(), array('FailOnAccessError'=>true), $user);
            }
        }
        $success = $client->Finalize($success);
    }
    if($client->exit)
        exit;
    if($success)
    {
        session_start();
        $_SESSION['userdata']=$user;
        header("location: index.php");
    }
    else
    {
      echo 'Error:'.HtmlSpecialChars($client->error); 
    }
?>

以下是在线查询的链接: - www.novostack.com/mcr/ 我的开发者控制台中确实有正确的设置。 这里似乎有什么问题?

所有建议都表示赞赏。

1 个答案:

答案 0 :(得分:0)

确保APP设置下的“根域”等于您的来电域名(www.novostack.com)。