Hit /user instead of /authorizations/token/<token>

This commit is contained in:
Kafonek, Matt
2021-04-09 15:01:48 +00:00
parent 86b51804c1
commit aebf833530

View File

@@ -41,8 +41,11 @@ async def get_current_user(
) )
async with get_client() as client: async with get_client() as client:
endpoint = "/authorizations/token/%s" % token endpoint = "/user"
resp = await client.get(endpoint) # normally we auth to Hub API with service api token,
# but this time auth as the user token to get user model
headers = {"Authorization": f"Bearer {token}"}
resp = await client.get(endpoint, headers=headers)
if resp.is_error: if resp.is_error:
raise HTTPException( raise HTTPException(
status.HTTP_400_BAD_REQUEST, status.HTTP_400_BAD_REQUEST,