Skip to content

Commit

Permalink
/me update (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
grigoriev-semyon authored Feb 13, 2023
1 parent 9524ce6 commit a9f9523
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions auth_lib/aiomethods.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ async def email_login(self, email: str, password: str) -> dict[str, Any]:
raise AuthFailed(response=await response.json())

async def check_token(self, token: str) -> dict[str, Any]:
headers = {"token": token}
headers = {"Authorization": token}
fields = frozenset(["email"])
async with aiohttp.ClientSession() as session:
response = await session.post(url=f"{self.url}/me", headers=headers)
response = await session.get(url=f"{self.url}/me", headers=headers, params={"info": ["groups", "indirect_groups"]})
match response.status:
case 200:
return await response.json()
Expand Down
5 changes: 3 additions & 2 deletions auth_lib/fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ async def __call__(
if not token:
return self._except()
async with aiohttp.request(
"POST",
"GET",
urljoin(self.auth_url, "/me"),
headers={"token": token},
headers={"Authorization": token},
params={"info": ["groups", "indirect_groups"]}
) as r:
status_code = r.status
user = await r.json()
Expand Down
6 changes: 3 additions & 3 deletions auth_lib/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from .exceptions import SessionExpired, AuthFailed, IncorrectData, NotFound


# See docs on https://auth.api.test.profcomff.com/docs
# See docs on https://auth.api.profcomff.com/docs


class AuthLib:
Expand All @@ -24,9 +24,9 @@ def email_login(self, email: str, password: str) -> dict[str, Any]:
raise AuthFailed(response=response.json()["body"])

def check_token(self, token: str) -> dict[str, Any]:
headers = {"token": token}
headers = {"Authorization": token}
fields = frozenset(["email"])
response = requests.post(url=f"{self.url}/me", headers=headers)
response = requests.get(url=f"{self.url}/me", headers=headers, params={"info": ["groups", "indirect_groups"]})
match response.status_code:
case 200:
return response.json()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="auth_lib_profcomff",
version="0.0.3",
version="0.0.4",
author="Semyon Grigoriev",
long_description=readme,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit a9f9523

Please sign in to comment.