Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.0a token is required to send tweet #61

Open
earthwytch opened this issue Jul 26, 2023 · 3 comments
Open

1.0a token is required to send tweet #61

earthwytch opened this issue Jul 26, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@earthwytch
Copy link

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 🤸‍♀️

@danieldevine danieldevine self-assigned this Jul 26, 2023
@danieldevine
Copy link
Owner

Hi, could you let me know which version of birdelephant you're using? I'm guessing this is a side effect of #57 but would like to confirm first. if you're currently using v0.7 then can you try rolling back to 0.6.1 and let me know what happens?

@earthwytch
Copy link
Author

Yes, that was v0.7 and yes, it is fixed now I have rolled back to 0.6.1 ✔️

@danieldevine
Copy link
Owner

ok, thanks very much for the report. I'll address the issue in the next release.

@danieldevine danieldevine added the bug Something isn't working label Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants