query-string-fix
This commit is contained in:
parent
0c73f376a2
commit
8ee7a1ffaa
|
@ -1,4 +1,3 @@
|
||||||
import json
|
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from httpx import AsyncClient, HTTPError
|
from httpx import AsyncClient, HTTPError
|
||||||
from settings import AUTH_URL
|
from settings import AUTH_URL
|
||||||
|
@ -10,14 +9,13 @@ INTERNAL_AUTH_SERVER = "v2.discours" in AUTH_URL or "testapi.discours" in AUTH_U
|
||||||
async def check_auth(req):
|
async def check_auth(req):
|
||||||
token = req.headers.get("Authorization")
|
token = req.headers.get("Authorization")
|
||||||
print(f"[services.auth] checking auth token: {token}")
|
print(f"[services.auth] checking auth token: {token}")
|
||||||
gql = (
|
gql = ("mutation { getSession { user { id } } }"
|
||||||
{"mutation": "{ getSession { user { id } } }"}
|
|
||||||
if INTERNAL_AUTH_SERVER
|
if INTERNAL_AUTH_SERVER
|
||||||
else {"query": "{ session { user { id } } }"}
|
else "query { session { user { id } } }"
|
||||||
)
|
)
|
||||||
headers = {"Authorization": token, "Content-Type": "application/json"}
|
headers = {"Authorization": token, "Content-Type": "application/json"}
|
||||||
async with AsyncClient() as client:
|
async with AsyncClient() as client:
|
||||||
response = await client.post(AUTH_URL, headers=headers, data=json.dumps(gql))
|
response = await client.post(AUTH_URL, headers=headers, data=gql)
|
||||||
print(f"{response.text}")
|
print(f"{response.text}")
|
||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
return False, None
|
return False, None
|
||||||
|
|
Loading…
Reference in New Issue
Block a user