Search code examples
laraveltwitteroauthlaravel-socialite

Twitter OAuth returns 401 invalid request token


I'm using Laravel Socialite (specifically this) and all of a sudden, I'm getting this when returning to the callback:

Received HTTP status code [401] with message "Invalid request token." when getting token credentials.

It used to work just fine. I've tried:

  • Deleting my test/dev application in Twitter Dev,
  • Regenerating my application keys,
  • Making sure the "Enable OAuth" option is checked,
  • Enabling the callback lock,

I'm completely stumped, as everything was working, and seems like it should be.


Solution

  • I fixed the same bug. You will work if you modify and override the following methods.

    SocialiteProviders\Manager\OAuth1\Server::getTokenCredentials()

    //$response = $client->post($uri, $headers, $bodyParameters)->send();
    $response = $client->post($uri, [
                    'headers' => $headers,
                    'form_params' => $bodyParameters,
    ]);