jessecooper / pyetrade

Python E-Trade API Wrapper
GNU General Public License v3.0
209 stars 97 forks source link

HTTP Status 401 - oauth_problem=signature_invalid #4

Closed AustinDeric closed 6 years ago

AustinDeric commented 6 years ago

I inserted my consumer_key and consumer_secret and i get the following error. I believe this is because the keys are bad, but i wanted to confirm.

- Error report

HTTP Status 401 - oauth_problem=signature_invalid


type Status report

message oauth_problem=signature_invalid

description This request requires HTTP authentication (oauth_problem=signature_invalid).


jessecooper commented 6 years ago

Can you please provide a sample of the code you are running when you get this issue?

AustinDeric commented 6 years ago
#python 3.5
import pyetrade #https://github.com/jessecooper/pyetrade

consumer_key = '[consumer key string provided by etrade]'
consumer_secret =  '[consumer secret string provided by etrade]'

oauth = pyetrade.ETradeOAuth(consumer_key, consumer_secret)
oauth.get_request_token()
#Follow url and get verification code

tokens = oauth.get_access_token(verifier_code)
accounts = pyetrade.ETradeAccounts(
        consumer_key,
        consumer_secret,
        tokens['oauth_token'],
        tokens['oauth_token_secret']
    )
accounts.list_accounts()

the error is returned by etrade servers at the oauth.get_request_token() function.

jessecooper commented 6 years ago

This is an interesting error because it points to the signature. I could see there being a system time issue if the system time is not accurate within 5 minutes:

oauth_timestamp integer The date and time of the request, in epoch time. Must be accurate within five minutes.

I did test this today and was able to get everything going successfully. Please check if it is the system time. I do not think it is the keys because it comes back saying your keys because the etrade api comes back with a similar 401 message but specifically stating its a key issue.

AustinDeric commented 6 years ago

~I am running ubuntu, the system time is automatically updates and looks good to me. Any way to test the system time? Or, is there anyway to debug/test this error? Maybe a time-zone issue?~

@jessecooper thank you for trying to help, you were more helpful than etrade. This issue is no longer relevent to me as i am going to use a different API.

Thanks though!

jessecooper commented 6 years ago

Just a closing note: all of my systems are in UTC that make these requests. Hope you find the right API for your project. Happy Hacking!