Skip to content

Commit

Permalink
headers fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xXxCLOTIxXx authored Apr 21, 2024
1 parent 2387626 commit 1e94343
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions amino/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Client(SocketHandler, Requester, Callbacks):
models.proxy_settings.SocketProxy *socket_proxy* - socket proxy settings (Default: SocketProxy())
"""

profile = ObjectCreator()
profile = ObjectCreator({"uid": None, })
active_live_chats = list()

def __init__(self,
Expand Down Expand Up @@ -92,7 +92,7 @@ def user_agent(self) -> str:


def get_headers(self, deviceId: str = None, data = None, content_type: str = None, sid: str = None, user_agent = None, language: str = None) -> dict:
return headers(deviceId=deviceId if deviceId else self.deviceId, data=data, content_type=content_type, sid=sid or self.profile.sid, user_agent=user_agent if user_agent else self.user_agent, language=language if language else self.language)
return headers(deviceId=deviceId if deviceId else self.deviceId, data=data, content_type=content_type, sid=sid or self.profile.sid, user_agent=user_agent if user_agent else self.user_agent, language=language if language else self.language, userId=self.profile.userId)

def set_device(self, deviceId: str = None, auto_device: bool = None, set_random_device: bool = False, user_agent: str = None, set_random_user_agent: bool = False) -> str:
if auto_device is True: self.auto_device = True
Expand Down Expand Up @@ -222,7 +222,7 @@ def logout(self) -> int:
})

response = self.make_request(method="POST", endpoint="/g/s/auth/logout", data=data, headers=self.get_headers(data=data, deviceId=deviceId))
self.profile = ObjectCreator()
self.profile = ObjectCreator({"uid": None, })
if self.socket_enabled:self.close()
return response.status_code

Expand Down
1 change: 1 addition & 0 deletions amino/helpers/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,7 @@ def __init__(*args, **kwargs):
}

def check_exceptions(data, status):
print(data)
try:
data = loads(data)
try:code = data["api:statuscode"]
Expand Down
13 changes: 7 additions & 6 deletions amino/helpers/headers.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
from .generators import generate_deviceId, signature
from uuid import uuid4

def headers(data = None, content_type = None, sid: str = None, deviceId: str = None, user_agent: str = "Apple iPhone12,1 iOS v15.5 Main/3.12.2", language: str = "en"):
def headers(data = None, content_type = None, sid: str = None, deviceId: str = None, user_agent: str = "Apple iPhone12,1 iOS v15.5 Main/3.12.2", language: str = "en", userId: str = None):
headers = {
"NDCDEVICEID": deviceId if deviceId else generate_deviceId(),
"NDCLANG": language.lower(),
"Accept-Language": f"{language.lower()}-{language.upper()}",
"SMDEVICEID": "20230109055041eecd2b9dd8439235afe4522cb5dacd26011dba6bbfeeb752",
"User-Agent": user_agent,
"Content-Type": "application/json; charset=utf-8",
"Host": "service.narvii.com",
"Accept-Encoding": "gzip",
"Connection": "Upgrade"
"Content-Type": "application/json",
"Host": "service.aminoapps.com",
"Accept-Encoding": "identity",
"Accept": "*/*",
"Connection": "keep-alive",
}
if data:
headers["Content-Length"] = str(len(data))
headers["NDC-MSG-SIG"] = signature(data=data)
if sid:headers["NDCAUTH"] = f"sid={sid}"
if content_type:headers["Content-Type"] = content_type
if userId: headers["AUID"] = userId
return headers

def ws_headers(final: str, sid: str = None, deviceId: str = None):
Expand Down

0 comments on commit 1e94343

Please sign in to comment.