1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"""QCS Middleware for requests made with `httpx`."""
"""An `httpx.Auth` that will add QCS authorization to your requests and refresh the token as needed.
Synchronous usage:
```python
import httpx
auth = QCSAuthorization()
client = httpx.Client(auth=auth)
response = client.get('https://rigetti.com/protected-resource')
```
Asynchronous usage:
```python
import httpx
import asyncio
async def main():
auth = QCSAuthorization()
async with httpx.AsyncClient(auth=auth) as client:
response = await client.get('https://rigetti.com/protected-resource')
print(response.status_code)
print(response.json())
asyncio.run(main())
```
"""
"""Initialize the authorization with an optional client configuration.
If `client_configuration` is set to None, `ClientConfiguration.load_default()` will be used.
"""
= or
# Note: No explicit type hints here. It confuses stubtest, and they are inherited from the base class anyways.
"""Add the QCS authorization token to the request, refreshing the token as needed."""
= await
= f
yield
"""Add the QCS authorization token to the request, refreshing the token as needed."""
=
= f
yield