Search code examples
phplaraveloauthtumblr

Laravel Tumblr OAuth - Failed to Request Resource


I'm getting the following error:

Screenshot of the error

I'm using artdarek's oauth-4-laravel but there doesn't seem to be much support in the Issues area.

My code is as follows:

public function tumblrLogin()
{
    $oauth_token = Input::get( 'oauth_token' );
    $oauth_verifier = Input::get( 'oauth_verifier' );
    $tumblr = OAuth::consumer('Tumblr', 'http://30daychallenges.net/auth/tumblr/');

    if ( !empty( $oauth_token ) && !empty( $oauth_verifier ) ) 
    {
        $token = $tumblr->retrieveAccessToken('Tumblr');
        $tumblr->requestAccessToken( $oauth_token, $oauth_verifier, $token->getRequestTokenSecret() );

        $result = json_decode( $tumblr->request('user/info'), true );

        dd($result);

    }
    else 
    {
        // get request token
        $token = $tumblr->requestRequestToken();
        // get Authorization Uri sending the request token
        $url = $tumblr->getAuthorizationUri(array('oauth_token' => $token->getRequestToken()));

        return Redirect::to( (string)$url );
    }
}

The error looks like it's coming from

$token = $tumblr->requestRequestToken();

But I can't see why - anyone experienced this error before?


Solution

  • Oh my. I feel like such an idiot.

    In /app/config/packages/artdarek/oauth-4-laravel/config.php I had the credentials in the array, however the array keys were consumer_key and consumer_secret, as Tumblr's API had suggested.

    The oauth-4-laravel package expects these to be client_id and client_secret uniformly, so this is my bad.