Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get session ID. Getting json.decoder.JSONDecodeError error #516

Open
eminenceviraj opened this issue Apr 12, 2024 · 4 comments
Open

Comments

@eminenceviraj
Copy link

eminenceviraj commented Apr 12, 2024

When I executed AliceBlue.login_and_get_sessionID() getting below error.

raceback (most recent call last):
File "C:\Python312\Lib\site-packages\requests\models.py", line 972, in json
return complexjson.loads(self.text, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python312\Lib\json_init_.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python312\Lib\json\decoder.py", line 338, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python312\Lib\json\decoder.py", line 356, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "E:\Viraj Imp\Share Market\Algo\TradingGreeks\generation.py", line 23, in
session_id = AliceBlue.login_and_get_sessionID(username="960159",
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python312\Lib\site-packages\alice_blue\alice_blue.py", line 216, in login_and_get_sessionID
isAuthorized = r.json()['isAuthorized']
^^^^^^^^
File "C:\Python312\Lib\site-packages\requests\models.py", line 976, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

@597743
Copy link

597743 commented Apr 17, 2024

i see same error how to solve it

@smnsivaprakash
Copy link

smnsivaprakash commented May 17, 2024

I'm also seeing the same error. Any fix available ?
this is with latest version

  • alice-blue 2.0.4

@GauthamPJ
Copy link

Facing the same issue as well.
2024-07-19 11:18:19,875 - INFO : _internal.py : _log : 97 : 127.0.0.1 - - [19/Jul/2024 11:18:19] "�[36mGET /ab?__debugger__=yes&cmd=resource&f=console.png HTTP/1.1�[0m" 304 - 2024-07-19 11:57:38,940 - DEBUG : connectionpool.py : _new_conn : 1051 : Starting new HTTPS connection (1): ant.aliceblueonline.com:443 2024-07-19 11:57:39,246 - DEBUG : connectionpool.py : _make_request : 546 : https://ant.aliceblueonline.com:443 "POST /rest/AliceBlueAPIService/customer/getEncryptionKey HTTP/11" 200 37 2024-07-19 11:57:39,246 - INFO : alice_blue.py : login_and_get_sessionID : 197 : Get Encryption Key response {"stat":"Ok","encKey":"valid-enc-key"} 2024-07-19 11:57:39,255 - DEBUG : connectionpool.py : _new_conn : 1051 : Starting new HTTPS connection (1): ant.aliceblueonline.com:443 2024-07-19 11:57:39,539 - DEBUG : connectionpool.py : _make_request : 546 : https://ant.aliceblueonline.com:443 "POST /rest/AliceBlueAPIService/customer/webLogin HTTP/11" 200 None 2024-07-19 11:57:39,539 - INFO : alice_blue.py : login_and_get_sessionID : 206 : Web Login response {"userId":"valid-user-id","accountId":null,"password":null,"newPassword":null,"oldPassword":null,"userSessionID":null,"userToken":null,"publicKey4":null,"stringPkey4":null,"publicKey3":null,"stringPkey3":null,"privatekey2":null,"stringPK2":null,"tomcatcount":null,"stat":"Ok","tdata":"Answer the questions","sQuestions":"Year Of Birth","sCount":"1","sIndex":"1","ques_Ans":null,"answer1":null,"answer2":null,"sUserToken":null,"sPasswordReset":null,"message":null,"exch":null,"symbol":null,"mwName":null,"email":null,"pan":null,"list":null,"preLogin":null,"userSettingDto":null,"is_mob":false,"dob":null,"scripList":null,"validAnsResponse":null,"webSocketID":null,"authorizationStatus":0,"expiryDate":0,"userApiKey":null,"vendorId":0,"vendorApiKey":null,"vendorSecret":null,"deviceId":null,"loginType":null,"callBackUrl":null,"loginMode":null,"vendor":null,"authCode":null,"version":null,"checkSum":null,"fcmToken":null,"imei":null,"source":null,"userData":null,"userDataNew":null,"tOtp":null,"emsg":null,"v2":false} 2024-07-19 11:57:39,539 - DEBUG : connectionpool.py : _new_conn : 1051 : Starting new HTTPS connection (1): ant.aliceblueonline.com:443 2024-07-19 11:57:39,787 - DEBUG : connectionpool.py : _make_request : 546 : https://ant.aliceblueonline.com:443 "POST /rest/AliceBlueAPIService/sso/validAnswer HTTP/11" 404 None 2024-07-19 11:57:39,790 - INFO : alice_blue.py : login_and_get_sessionID : 215 : Web Login 2FA response <!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title><script src="/cdn-cgi/apps/head/LevqwntdubYOQ1V1cUP6VynfEJ0.js"></script><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 404 – Not Found</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> Not Found</p><p><b>Description</b> The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.</p><hr class="line" /><h3>Apache Tomcat/9.0.78</h3></body></html> 2024-07-19 11:57:39,806 - INFO : _internal.py : _log : 97 : 127.0.0.1 - - [19/Jul/2024 11:57:39] "�[35m�[1mGET /ab HTTP/1.1�[0m" 500 - 2024-07-19 11:57:39,837 - INFO : _internal.py : _log : 97 : 127.0.0.1 - - [19/Jul/2024 11:57:39] "GET /ab?__debugger__=yes&cmd=resource&f=style.css HTTP/1.1" 200 - 2024-07-19 11:57:39,837 - INFO : _internal.py : _log : 97 : 127.0.0.1 - - [19/Jul/2024 11:57:39] "GET /ab?__debugger__=yes&cmd=resource&f=debugger.js HTTP/1.1" 200 - 2024-07-19 11:57:39,868 - INFO : _internal.py : _log : 97 : 127.0.0.1 - - [19/Jul/2024 11:57:39] "GET /ab?__debugger__=yes&cmd=resource&f=console.png HTTP/1.1" 200 -

@sonikush
Copy link

I am also getting same error, is there any way to resolve it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants