You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use the token to make authenticated requests to any Openapi service.
93
94
94
95
```python
95
-
from openapi_python_sdk.clientimport Client
96
+
from openapi_python_sdk import Client
96
97
97
98
client = Client(token=token)
98
99
@@ -111,6 +112,37 @@ resp = client.request(
111
112
)
112
113
```
113
114
115
+
## Async Usage
116
+
117
+
The SDK provides `AsyncClient` and `AsyncOauthClient` for use with asynchronous frameworks like FastAPI or `aiohttp`.
118
+
119
+
### Async Authentication
120
+
121
+
```python
122
+
from openapi_python_sdk import AsyncOauthClient
123
+
124
+
asyncwith AsyncOauthClient(username="<your_username>", apikey="<your_apikey>", test=True) as oauth:
125
+
resp =await oauth.create_token(
126
+
scopes=["GET:test.imprese.openapi.it/advance"],
127
+
ttl=3600,
128
+
)
129
+
token = resp["token"]
130
+
```
131
+
132
+
### Async Requests
133
+
134
+
```python
135
+
from openapi_python_sdk import AsyncClient
136
+
137
+
asyncwith AsyncClient(token=token) as client:
138
+
resp =await client.request(
139
+
method="GET",
140
+
url="https://test.imprese.openapi.it/advance",
141
+
params={"denominazione": "altravia"},
142
+
)
143
+
```
144
+
145
+
114
146
## Testing
115
147
116
148
Install dev dependencies and run the test suite:
@@ -174,4 +206,3 @@ The MIT License is a permissive open-source license that allows you to freely us
174
206
In short, you are free to use this SDK in your personal, academic, or commercial projects, with minimal restrictions. The project is provided "as-is", without any warranty of any kind, either expressed or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non-infringement.
175
207
176
208
For more details, see the full license text at the [MIT License page](https://choosealicense.com/licenses/mit/).
0 commit comments