I have 2 website, 'connector' and 'provider'. I want to use connector get the 'user index' resource. So I opened the 'login', 'logout', 'index', create an alias "userinfo" for 'user' resource, and tested, it works well.
Then I choose 'Required authentication' : 'Consumer Key'; 'Required authorization':'Default' for 'login', 'logout', 'index'. Now I get an error: Already logged in as drupal_connector.
//...
function myservice_user(){
//..some code here
$service = new MySimpleService($connector, $token, 'myservice_change_cookie_header');
$account = array('username' => 'admin', 'password' => 'admin');
$session_info = $service->excute('http://provider-test.localhost/oauthlogin/api/userinfo/login', 'post', $account);
dsm($session_info);
$callback = $service->excute('http://provider-test.localhost/oauthlogin/api/userinfo', 'get', $session_info);
dsm($callback);
$logoutinfo = $service->excute('http://provider-test.localhost/oauthlogin/api/userinfo/logout', 'post', $account,$session_info);
dsm($logoutinfo);
return serialize($callback);
}
I debug the project and I found these code in the end:
service_oauth.inc line 82, user was set to consumer account
else if ($cred == 'consumer') {
if ($consumer->uid) {
// This authenticates as the user who owns 'key'; It is for 2-stage
// OAuth and is vastly inferior to 3-stage OAuth
global $user;
$user = user_load($consumer->uid);
}
}
service.module line 352, if the callback is login, user will not set to $original_user
//For every callback that has nothing to do with login we need to
//set it to the original user so that they are no longer anonymous
if (strpos($arg[1]['callback'], 'login') === FALSE) {
// The account should be restored to the session's user.
$user = $original_user;
}
Does anyone can help me on this question? how can I get the user info by 2-legged authentication? Thanks a lot!!!
| Comment | File | Size | Author |
|---|---|---|---|
| connector_error.jpg | 204.66 KB | wangjiaqi | |
| provider_settings.jpg | 54.16 KB | wangjiaqi |
Comments
Comment #1
marcingy commentedDrupal 6 is no longer supported