File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -12,4 +12,39 @@ This transport uses the `aiohttp`_ library and allows you to send GraphQL querie
12
12
13
13
.. literalinclude :: ../code_examples/aiohttp_async.py
14
14
15
+ Authentication
16
+ --------------
17
+
18
+ There are multiple ways to authenticate depending on the server configuration.
19
+
20
+ 1. Using HTTP Headers
21
+
22
+ .. code-block :: python
23
+
24
+ transport = AIOHTTPTransport(
25
+ url = ' https://SERVER_URL:SERVER_PORT/graphql' ,
26
+ headers = {' Authorization' : ' token' }
27
+ )
28
+
29
+ 2. Using HTTP Cookies
30
+
31
+ You can manually set the cookies which will be sent with each connection:
32
+
33
+ .. code-block :: python
34
+
35
+ transport = AIOHTTPTransport(url = url, cookies = {" cookie1" : " val1" })
36
+
37
+ Or you can use a cookie jar to save cookies set from the backend and reuse them later.
38
+
39
+ In some cases, the server will set some connection cookies after a successful login mutation
40
+ and you can save these cookies in a cookie jar to reuse them in a following connection
41
+ (See `issue 197 `_):
42
+
43
+ .. code-block :: python
44
+
45
+ jar = aiohttp.CookieJar()
46
+ transport = AIOHTTPTransport(url = url, client_session_args = {' cookie_jar' : jar})
47
+
48
+
15
49
.. _aiohttp : https://docs.aiohttp.org
50
+ .. _issue 197 : https://github.com/graphql-python/gql/issues/197
You can’t perform that action at this time.
0 commit comments