Unable to get access token

rksingh
rksingh edited December 2017 in General
Hi,
Please check why I am getting error while requesting for access token. (Client ID : DR0283)
I tried 3 times - within a minute after getting request token..
Getting same error each time

hecksum

File "C:\Users\USER\Anaconda3\lib\site-packages\kiteconnect\__init__.py", line 581, in _post
return self._request(route, "POST", params)

File "C:\Users\USER\Anaconda3\lib\site-packages\kiteconnect\__init__.py", line 668, in _request
raise(exp(data["message"], code=r.status_code))

TokenException: Invalid session credentials


========================== MY CODE ++++++++++++++++++++++++++++++++++++++++++++
from kiteconnect import KiteConnect

# initialise all variables we need
api_key = "xxxxxxxxxxxxxxxxxxxxxxxx"
client_id = "DR0283"

obtained_request_token = "xxxxxxxxxxxxxxxxxxxxxxx"
api_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"

kite = KiteConnect(api_key=api_key)

try:
user = kite.request_access_token(request_token="obtained_request_token",secret=api_secret)
print("Access Token --> ", user["access_token"])
except Exception as e:
print("Authentication failed", str(e))
raise
  • sujith
    Hi,
    The request token can be used only once and it is valid for a couple of minutes. A user can't re-use request token.
  • rksingh
    Sujith - you didn't understand my problem.
    I said that, I generated request token and used it within a minute (didn't wait long) to generate access token. Still I get error as said in my previous message.

    As I was getting error, I tried this process 3 times. I tried again now..still same issue.

    Please help. I paid for subscription, but unable to trade...
  • sujith
    Everything seems to be fine with your account. We do it almost every day. It is working fine.

    You can check out webinar for login flow.
Sign In or Register to comment.