oauth-4-laravel
oauth-4-laravel copied to clipboard
requestAccessToken() errors: "Failed to request resource."
When running:
/**
* Get Facebook sDK
*/
$fb = OAuth::consumer( 'Facebook' );
/**
* Set code
*/
$fb->requestAccessToken($facebook_token); // this line
I'll get the error:
"Failed to request resource."
Why?
I get the same error when using $googleService->requestAccessToken( $code );
For some reason, in Lusitanian it gets 'false' back from google.
I didn't any problems with facebook, it works well for me, but not with twitter.
// get request token
$reqToken = $tw->requestRequestToken();
// get Authorization Uri sending the request token
$url = $tw->getAuthorizationUri(array('oauth_token' => $reqToken->getRequestToken()));
// return to twitter login url
return Redirect::to( (string)$url );
It get requestAccessToken() errors: "Failed to request resource." when call requestRequestToken();
when I manually use curl to request token, it returned the access token and directly input to this methods:
$url = $tw->getAuthorizationUri(array('oauth_token' => 'manually input access token'));
and it works returned PIN.
so twitter authentication process working, but not with method requestRequestToken(), anyone !?
I am still experincing this issue. Anyone would know why?
Try to pass the OAuth redirect URIs manually - facebook goes all willy-nilly about missing trailing slashes.
What do you mean Rani?
After debugging, this is the request that fails:
https://graph.facebook.com/oauth/access_token
$fb = OAuth::consumer( 'Facebook','http://my.app.com/' ); Instead of $fb = OAuth::consumer( 'Facebook');
This will send the redirect URI with trailing a slash, which doesn't always happen automatically, and which facebook insists on.
Ah, I see. I've tried. Still, without luck.
Anyways, shouldn't facebook return a error message if this was the issue?
It does, and returns it in the body, but the inner function doesn't read it.
You have to make a change to lusitanian\oauth\src\OAuth\Common\Http\Client\StreamClient.php, at about line 50, to make it make a request with "ignore errors" on, and read the response body.
Take a look at this stackexchange thread: http://stackoverflow.com/questions/3710147/php-get-content-of-http-400-response
Thanks Rani, I've tried implementing that, but it does not work.
Fun thing is, query takes 22 seconds before it fails (tried extending timeout period, no affect, still around 22seconds).
My staging server works perfectly - strange - maybe some Facebook domain configuration that is not correct, but since I don't get any error responses as to why request fails (!!), I have no idea where to start.
That is odd. Maybe you should try inspecting $http_response_header - at least you'll which status code is returned, if any.
Same problem, i'm the developer of the app and with my fb account all works fine, but with other users and with "/me/taggable_friends" does not work :S