Exception error occured

when try to run sesson 7 live algo the following error occured.
‘request_token’
Traceback (most recent call last):
File “C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\Zerodha_Tradehull\Zerodha_Tradehull.py”, line 63, in init
self.kite = self.get_login(api_key,api_secret)
File “C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\Zerodha_Tradehull\Zerodha_Tradehull.py”, line 144, in get_login
request_tkn = parse_qs(urlparse(token_url).query)[‘request_token’][0]
KeyError: ‘request_token’
Traceback (most recent call last):
File “d:/Dhan/MentershipAlgo/Session 7/Session 7/Live algo - Copy.py”, line 20, in
sheet = book.sheets[“orderbook”]
File “C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\xlwings\main.py”, line 89, in getitem
return self(key)
File “C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\xlwings\main.py”, line 5214, in call
return Sheet(impl=self.impl(name_or_index))
File “C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\xlwings_xlwindows.py”, line 943, in call
return Sheet(xl=self.xl(name_or_index))
File “C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\xlwings_xlwindows.py”, line 236, in call
v = self._inner(*args, **kwargs)
File “C:\Users\Admin\AppData\Local\Temp\gen_py\3.8\00020813-0000-0000-C000-000000000046x0x1x9.py”, line 36620, in call
ret = self.oleobj.InvokeTypes(0, LCID, 2, (9, 0), ((12, 1),),Index
what to do?

Hi @mn.prasannakumarmn ,

It means the URL your code is parsing doesn’t contain a request_token query param:

  • You pasted the login page URL instead of the final redirected URL after successful login/2FA
  • The session expired or the URL was truncated
  • Wrong api_key is used
    Please validate all these points.