oauth-4-laravel
oauth-4-laravel copied to clipboard
Twitter OAuth Error Failed to request resource.
I have looked at every issue I could find and no one seems to have an answer to how to get twitter OAuth setup. Here is my config file
<?php
return array(
//Storage
'storage' => 'Session',
// Consumers
'consumers' => array(
//Twitter
'Twitter' => array(
'key' => '*************************',
'secret' => '****************************************************',
),
)
);
This is setup I believe it is correct through #5, #7 and #15. Then I have the following method (obtained from the same issues)
public function loginWithTwitter()
{
$oauth_token = Input::get('oauth_token');
$oauth_verifier = Input::get('oauth_verifier');
// get service
$twit = OAuth::consumer('Twitter');
// check if code is valid
// if code is provided get user data and sign in
if (!empty($oauth_token)) {
// This was a callback request from google, get the token
$token = $twit->requestAccessToken($oauth_token, $oauth_verifier);
// Send a request with it
$result = json_decode( $twit->request( 'account/verify_credentials.json' ), true );
echo print_r($result);
}
// if not ask for permission first
else
{
// get authorization
$token = $twit->requestRequestToken();
$url = $twit->getAuthorizationUri(array('oauth_token' => $token->getRequestToken()));
// return to login url
return Response::make()->header( 'Location', (string)$url );
}
}
This produces the error OAuth \ Common \ Http \ Exception \ TokenResponseException Failed to request resource. This is happening from line
$token = $twit->requestRequestToken();
Is there something else that needs to happen for this to work? a php.ini setting? something in my code? Thanks
configuration for twitter should look like this:
'Twitter' => [
'client_id' => '***********************************',
'client_secret' => '*****************************',
'scope' => array(),
],
Why isn't this in the readme? Seems silly to have it here in an issue and not upfront. Not very user friendly.