koenrh / delete-tweets

Delete tweets from your timeline.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Twitter API credentials not set.

jaybird34 opened this issue · comments

Hi koenrh,

Running from a command line (not BASH), I keep getting "Twitter API credentials not set." even though I've set them where specified in two places. I'm not sure if it's something I'm doing or if others are experiencing similar. Thank you.

Did you export the variables to your environment as described in this section?

That is (note the export command):

export TWITTER_CONSUMER_KEY="[your consumer key]"
export TWITTER_CONSUMER_SECRET="[your consumer secret]"
export TWITTER_ACCESS_TOKEN="[your access token]"
export TWITTER_ACCESS_TOKEN_SECRET="[your access token secret]"

No worries.

No, the export command is Bash (which is a particular shell) built-in command. You need to run that command in your shell, which usually is Bash. You access that shell in a terminal app (e.g. Terminal.app on Mac, Command Prompt/cmd.exe on Windows).

What OS are you running? Windows?

Do I just type out "export(stuff goes here)" in the command line from cmd.exe?

No, the syntax is a little different. I'm not that familiar with the Windows 'Command Prompt', but as far as I understand you could set the environment variables as follows (no quotes or brackets):

set TWITTER_CONSUMER_KEY=[your consumer key]
set TWITTER_CONSUMER_SECRET=[your consumer secret]
set TWITTER_ACCESS_TOKEN=[your access token]
set TWITTER_ACCESS_TOKEN_SECRET=[your access token secret]

After which you could probably run the script using the Python executable:

python.exe deletetweets.py ...

Let me know if that works. I'll update the README to add instructions for Windows users.

I'll see if I can get my hands on a Windows (virtual) machine to test it myself.

Did you attach an image? (I don't see it show up on GitHub)

Please reopen if needed.

Hello,
I'm using Bash (on Windows with the Linux subsystem), everything should be working but I get the same error. I checked my ENV variables and all of them are there :/

Edit: Tried to set the env variables directly on Windows and it worked BUT I get this error
"Exception: [{'code': 215, 'message': 'Bad Authentication data.'}]"

I double checked the credentials and they are correct (even created a new app ...)

Edit2: I replaced the os.env part of your code directly with my tokens and it works just fine

@viktae That is odd. I don't run Windows myself, but I'll see if I can reproduce it in a Windows VM. Thanks for reporting!

Hi,
I encountered same issue, I used only windows, then Ubuntu on windows and got 215 error.
I got advice to hardcode your code and to remove os.env part and to directly enter my tokens and keys, but sadly I am not experienced that much yet, so would love if @viktae shared it with us.

If you need more feedback concerning this issue, I am here to send you data if you need them, because you don't use Windows.

@FejkImer That likely means that the script could somehow not read the environment variables.

After you have set the keys and tokens (per these instructions), could you check whether the variables are actually set?

Running this command should output the four Twitter environment variables: env | grep TWITTER

Here it is, I am using Ubuntu on Windows in this case

https://i.imgur.com/fJZhPSP.png

@FejkImer Apologies for the delay. You should not include the brackets [ ] here:

set TWITTER_CONSUMER_KEY=[your consumer key]
set TWITTER_CONSUMER_SECRET=[your consumer secret]
set TWITTER_ACCESS_TOKEN=[your access token]
set TWITTER_ACCESS_TOKEN_SECRET=[your access token secret]

It is safer to just quote these values:

set TWITTER_CONSUMER_KEY="YOUR_CONSUMER_KEY"
set TWITTER_CONSUMER_SECRET="YOUR_CONSUMER_SECRET"
set TWITTER_ACCESS_TOKEN="YOUR_ACCESS_TOKEN"
set TWITTER_ACCESS_TOKEN_SECRET="YOUR_ACCESS_TOKEN_SECRET"

I'll make sure to clarify that in the README.