Skip to content

Commit

Permalink
set access token and remove payload before new request
Browse files Browse the repository at this point in the history
  • Loading branch information
JenishSiifl committed Mar 27, 2024
1 parent edef647 commit 033a3ed
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions py5paisa/py5paisa.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def order_request(self, req_type) -> None:
raise Exception("Invalid request type!")
res = self.session.post(url, json=self.payload,
headers=HEADERS).json()

self.payload={}
if req_type == "MS":
log_response(res["head"]["statusDescription"])
else:
Expand Down Expand Up @@ -738,6 +738,7 @@ def get_access_token(self, request_token=None):
url = ACCESS_TOKEN_ROUTE

res = self.session.post(url, json=self.payload).json()
self.payload={}
message = res["body"]["Message"]

if message == "Success":
Expand All @@ -760,6 +761,7 @@ def get_request_token(self, client_code, totp, pin):
url = GET_REQUEST_TOKEN_ROUTE

res = self.session.post(url, json=self.payload).json()
self.payload={}
message = res["body"]["Status"]

if message == 0:
Expand Down Expand Up @@ -982,4 +984,10 @@ def place_order_bulk(self, **order):
# Handle unknown order_type if needed
pass
except Exception as e:
log_response(e)
log_response(e)


def set_access_token(self,accessToken,clientCode):
self.access_token=accessToken
self.client_code=clientCode
self.Jwt_token = self.access_token

0 comments on commit 033a3ed

Please sign in to comment.