Skip to content

1.0a token is required to send tweet #61

@earthwytch

Description

@earthwytch

I have a 'this used to work' problem 😬 (sorry!) I am using Laravel to automate a tweet.

            $credentials = array(
                'consumer_key' => env('TWITTER_CONSUMER_KEY'),
                'consumer_secret' => env('TWITTER_CONSUMER_SECRET'),
                'bearer_token' => env('TWITTER_BEARER_TOKEN'),
                'auth_token' => $token,
            );
    
            $twitter = new BirdElephant($credentials);
            $tweet = (new Tweet)->text($tweetText);
            $tweetResult = $twitter->tweets()->tweet($tweet);

First, I started receiving 'Class "Coderjerk\BirdElephant\InvalidArgumentException" not found' when I tried to tweet. So to debug, I changed the following and then got the correct error message.

Coderjerk\BirdElephant\Request
throw new \InvalidArgumentException('A 1.0a token is required for this endpoint.');

But I feel like I should actually be doing a bearerTokenRequest as I have successfully created an oAuth 2.0 auth_token. To test this I added $signed = false to Coderjerk\BirdElephant\Request and it all worked correctly - tweet was tweeted 🍾

Coderjerk\BirdElephant\Request

       $signed = false;

        if ($signed === true && (empty($this->credentials['token_identifier']) || empty($this->credentials['token_secret']))) {

            throw new \InvalidArgumentException('A 1.0a token is required for this endpoint.');

        }

        if ($signed === false && (isset($this->credentials['auth_token']) || isset($this->credentials['bearer_token'])) ) {

            return $this->bearerTokenRequest(
                $args,
                $this->credentials['auth_token'] ?? $this->credentials['bearer_token']
            );

        }

If the problem is that I genuinely am supposed to only use oAuth 1.0a then I can't understand why this worked before and why it works fine if I hack it to force $signed to be false. Am I missing an argument or something that tells it I want to use oAuth 2.0?

Thank you 🤸‍♀️

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions