2014-06-25 186 views
0

我想添加微软登录到我正在开发的应用程序,但我一再得到这个我无法理解的错误。微软oAuth似乎并没有工作

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/ 我做在我的开发者控制台中有正确的设置。 这里似乎是什么问题?

所有的建议表示赞赏。

回答

0

确保“APP设置”下的“根域”等于您的呼叫者域(www.novostack.com)。