Problem with loading credentials through search-tweets



I have recently purchased a premium, full-archive subscription. First, I generated bearer-token using this Java code. But I use Python code “search-tweets” for retrieving data. But somehow I cannot manage to load the credentials. I keep receiving the following error:

File “c:\python36\lib\site-packages\searchtweets\”, line 104, in _parse_credentials
raise KeyError

This is the code I am using:

from searchtweets import ResultStream, gen_rule_payload, load_credentials
premium_search_args = load_credentials("~/.twitter_keys.yaml",
                                       yaml_key= "search_tweets_api",
                                       account_type= "premium",

And this is the code in “.twitter_keys.yaml”:

  account_type: premium
  bearer_token: <..........>

I’m not sure whether there is something wrong with my yaml file, or the way I generated it? I’m still new to Python. Even though I retrieved data using my standard account before, this is the first time I use a premium account with search-tweets code. I appreciate your help!

Thanks a million in advance.


Hi @semuhi
A couple things to troubleshoot-



Thank you so much for your kind response.

I have just changed yaml file for credentials using only the consumer key and consumer key secret, and double-checked again the dev environment name, which is correctly specified in the document. Unfortunately, it did not work out. :frowning:

Any ideas?



No one? Any ideas?
I downgraded back to the sandbox again. :frowning:



I am sorry you’re having issues with the library. After your latest change, by putting the consumer key and secret in the file, what error message were you getting? is it still a KeyError?

Also, which version of the library are you using? I’d suggest bumping up to the latest version; we’ve released a few iterations in the last week.