api: login with oauth
This commit is contained in:
parent
10e5754e24
commit
41cbd84a74
1 changed files with 19 additions and 2 deletions
|
@ -27,6 +27,23 @@
|
||||||
* Simple HTTP Login
|
* Simple HTTP Login
|
||||||
*/
|
*/
|
||||||
function api_login(&$a){
|
function api_login(&$a){
|
||||||
|
// login with oauth
|
||||||
|
try{
|
||||||
|
$oauth = new FKOAuth1();
|
||||||
|
list($consumer,$token) = $oauth->verify_request(OAuthRequest::from_request());
|
||||||
|
if (!is_null($token)){
|
||||||
|
$oauth->loginUser($token->uid);
|
||||||
|
call_hooks('logged_in', $a->user);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
echo __file__.__line__.__function__."<pre>"; var_dump($consumer, $token); die();
|
||||||
|
}catch(Exception $e){
|
||||||
|
logger(__file__.__line__.__function__."\n".$e);
|
||||||
|
//die(__file__.__line__.__function__."<pre>".$e); die();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// workaround for HTTP-auth in CGI mode
|
// workaround for HTTP-auth in CGI mode
|
||||||
if(x($_SERVER,'REDIRECT_REMOTE_USER')) {
|
if(x($_SERVER,'REDIRECT_REMOTE_USER')) {
|
||||||
$userpass = base64_decode(substr($_SERVER["REDIRECT_REMOTE_USER"],6)) ;
|
$userpass = base64_decode(substr($_SERVER["REDIRECT_REMOTE_USER"],6)) ;
|
||||||
|
@ -1145,7 +1162,7 @@
|
||||||
}catch(Exception $e){
|
}catch(Exception $e){
|
||||||
echo "error=". OAuthUtil::urlencode_rfc3986($e->getMessage()); killme();
|
echo "error=". OAuthUtil::urlencode_rfc3986($e->getMessage()); killme();
|
||||||
}
|
}
|
||||||
echo "oauth_token=".$r->key."&oauth_secret=".$r->secret;
|
echo $r;
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
function api_oauth_access_token(&$a, $type){
|
function api_oauth_access_token(&$a, $type){
|
||||||
|
@ -1155,7 +1172,7 @@
|
||||||
}catch(Exception $e){
|
}catch(Exception $e){
|
||||||
echo "error=". OAuthUtil::urlencode_rfc3986($e->getMessage()); killme();
|
echo "error=". OAuthUtil::urlencode_rfc3986($e->getMessage()); killme();
|
||||||
}
|
}
|
||||||
echo "oauth_token=".$r->key."&oauth_secret=".$r->secret;
|
echo $r;
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue