py-trello icon indicating copy to clipboard operation
py-trello copied to clipboard

Bit of straightening out about the environment variables.

Open rkiddy opened this issue 9 years ago • 2 comments

Trying to make this a bit more clear for someone first using it.

It would also be easier if there was a way to set the ivar values via the command line or in a resource file. As it is now, I get:

$ python ./trello/util.py Traceback (most recent call last): File "./trello/util.py", line 91, in create_oauth_token() File "./trello/util.py", line 24, in create_oauth_token trello_key = key or os.environ['TRELLO_API_KEY'] File "/usr/lib/python2.7/UserDict.py", line 23, in getitem raise KeyError(key) KeyError: 'TRELLO_API_KEY' $ $ echo $TRELLO_API_KEY 2b6790f8042489d77227f3a632ae0add $

So, the environment variable is set, but not in the right way?

FYI, I am on an Ubuntu 14.04 system.

Also, your TrelloClient requires a:

  • api_key='your-key'
  • api_secret='your-secret'
  • token='your-oauth-token-key'
  • token_secret='your-oauth-token-secret'

I can see what the first three are. What is a token_secret? I get the OAuth token and ... that is it.

rkiddy avatar Jun 23 '15 03:06 rkiddy

I'm not sure why it is not picking up your TRELLO_API_KEY. I have no issues using this:

$ uname -a
Darwin masamune 14.3.0 Darwin Kernel Version 14.3.0: Mon Mar 23 11:59:05 PDT 2015; root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64

$ python --version
Python 2.7.9

$ echo $TRELLO_API_KEY
foo

$ python ./trello/util.py
Traceback (most recent call last):
  File "./trello/util.py", line 91, in <module>
    create_oauth_token()
  File "./trello/util.py", line 33, in create_oauth_token
    response = session.fetch_request_token(request_token_url)
  File "/usr/local/lib/python2.7/site-packages/requests_oauthlib/oauth1_session.py", line 261, in fetch_request_token
    token = self._fetch_token(url)
  File "/usr/local/lib/python2.7/site-packages/requests_oauthlib/oauth1_session.py", line 344, in _fetch_token
    raise TokenRequestDenied(error % (r.status_code, r.text), r.status_code)
requests_oauthlib.oauth1_session.TokenRequestDenied: Token request failed with code 500, response was 'App not found'.

Last I tried, it was working on Ubuntu, as well.

As to the token_secret, that is due to the fact that py-trello is utilizing OAuth 1.0 to authenticate to Trello. In 1.0, tokens are used in pairs (typically token and token_secret - see this).

sarumont avatar Jun 24 '15 23:06 sarumont

Hi @rkiddy ! You get token_secret after you use python -m trello oauth to get your Trello OAuth token. About your environment variables issue - I suggest you to check again how you configured your environment variables, as it seems there isn't a problem at instructions nor the code itself. Tested using python2.7 and python3.10 and worked fine. You also can here the full way (from configuring env. vars to the error) in order to help us examine the issue. Thanks

HomiGrotas avatar Feb 07 '23 08:02 HomiGrotas