I am trying to implement Github authentication in my application (built using Laravel 4) using php-github-api by KnpLabs. I went ahead and created an app in my Github account to obtain the client_id and the secret key.
The problem is, I cannot authenticate using this library. A null result is returned. It implementation seems simple but I cannot get it work. Checkout how I am implementing it.
try{
$client = new Github\Client();
$auth= $client->authenticate('myclientid','mysecret',AUTH_URL_CLIENT_ID);
$emails = $client->api('current_user')->emails()->all();
return Response::json(array("user"=>$emails));
}catch(Exception $e){
return Response::json(array('failed',$e->getMessage()));
}
This is the result I get from the above:
["failed","Requires authentication"]
Please someone help me figure out what I am doing wrong.
Thank you.