| 1 |
|
| 2 |
|
| 3 |
import typing |
| 4 |
|
| 5 |
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper |
| 6 |
from ..core.pagination import AsyncPager, SyncPager |
| 7 |
from ..core.request_options import RequestOptions |
| 8 |
from ..types.get_refresh_token_response_content import GetRefreshTokenResponseContent |
| 9 |
from ..types.get_refresh_tokens_paginated_response_content import GetRefreshTokensPaginatedResponseContent |
| 10 |
from ..types.refresh_token_metadata import RefreshTokenMetadata |
| 11 |
from ..types.refresh_token_response_content import RefreshTokenResponseContent |
| 12 |
from ..types.update_refresh_token_response_content import UpdateRefreshTokenResponseContent |
| 13 |
from .raw_client import AsyncRawRefreshTokensClient, RawRefreshTokensClient |
| 14 |
|
| 15 |
|
| 16 |
OMIT = typing.cast(typing.Any, ...) |
| 17 |
|
| 18 |
|
| 19 |
class RefreshTokensClient: |
| 20 |
def __init__(self, *, client_wrapper: SyncClientWrapper): |
| 21 |
self._raw_client = RawRefreshTokensClient(client_wrapper=client_wrapper) |
| 22 |
|
| 23 |
@property |
| 24 |
def with_raw_response(self) -> RawRefreshTokensClient: |
| 25 |
""" |
| 26 |
Retrieves a raw implementation of this client that returns raw responses. |
| 27 |
|
| 28 |
Returns |
| 29 |
------- |
| 30 |
RawRefreshTokensClient |
| 31 |
""" |
| 32 |
return self._raw_client |
| 33 |
|
| 34 |
def list( |
| 35 |
self, |
| 36 |
*, |
| 37 |
user_id: str, |
| 38 |
client_id: typing.Optional[str] = None, |
| 39 |
from_: typing.Optional[str] = None, |
| 40 |
take: typing.Optional[int] = 50, |
| 41 |
fields: typing.Optional[str] = None, |
| 42 |
include_fields: typing.Optional[bool] = None, |
| 43 |
request_options: typing.Optional[RequestOptions] = None, |
| 44 |
) -> SyncPager[RefreshTokenResponseContent, GetRefreshTokensPaginatedResponseContent]: |
| 45 |
""" |
| 46 |
Retrieve a paginated list of refresh tokens for a specific user, with optional filtering by client ID. Results are sorted by credential_id ascending. |
| 47 |
|
| 48 |
Parameters |
| 49 |
---------- |
| 50 |
user_id : str |
| 51 |
ID of the user whose refresh tokens to retrieve. Required. |
| 52 |
|
| 53 |
client_id : typing.Optional[str] |
| 54 |
Filter results by client ID. Only valid when user_id is provided. |
| 55 |
|
| 56 |
from_ : typing.Optional[str] |
| 57 |
An opaque cursor from which to start the selection (exclusive). Expires after 24 hours. Obtained from the next property of a previous response. |
| 58 |
|
| 59 |
take : typing.Optional[int] |
| 60 |
Number of results per page. Defaults to 50. |
| 61 |
|
| 62 |
fields : typing.Optional[str] |
| 63 |
Comma-separated list of fields to include or exclude (based on value provided for include_fields) in the result. Leave empty to retrieve all fields. |
| 64 |
|
| 65 |
include_fields : typing.Optional[bool] |
| 66 |
Whether specified fields are to be included (true) or excluded (false). |
| 67 |
|
| 68 |
request_options : typing.Optional[RequestOptions] |
| 69 |
Request-specific configuration. |
| 70 |
|
| 71 |
Returns |
| 72 |
------- |
| 73 |
SyncPager[RefreshTokenResponseContent, GetRefreshTokensPaginatedResponseContent] |
| 74 |
The refresh tokens were retrieved. |
| 75 |
|
| 76 |
Examples |
| 77 |
-------- |
| 78 |
from auth0 import Auth0 |
| 79 |
|
| 80 |
client = Auth0( |
| 81 |
token="YOUR_TOKEN", |
| 82 |
) |
| 83 |
response = client.refresh_tokens.list( |
| 84 |
user_id="user_id", |
| 85 |
client_id="client_id", |
| 86 |
from_="from", |
| 87 |
take=1, |
| 88 |
fields="fields", |
| 89 |
include_fields=True, |
| 90 |
) |
| 91 |
for item in response: |
| 92 |
yield item |
| 93 |
# alternatively, you can paginate page-by-page |
| 94 |
for page in response.iter_pages(): |
| 95 |
yield page |
| 96 |
""" |
| 97 |
return self._raw_client.list( |
| 98 |
user_id=user_id, |
| 99 |
client_id=client_id, |
| 100 |
from_=from_, |
| 101 |
take=take, |
| 102 |
fields=fields, |
| 103 |
include_fields=include_fields, |
| 104 |
request_options=request_options, |
| 105 |
) |
| 106 |
|
| 107 |
def revoke( |
| 108 |
self, |
| 109 |
*, |
| 110 |
ids: typing.Optional[typing.Sequence[str]] = OMIT, |
| 111 |
user_id: typing.Optional[str] = OMIT, |
| 112 |
client_id: typing.Optional[str] = OMIT, |
| 113 |
audience: typing.Optional[str] = OMIT, |
| 114 |
request_options: typing.Optional[RequestOptions] = None, |
| 115 |
) -> None: |
| 116 |
""" |
| 117 |
Revoke refresh tokens in bulk by ID list, user, user+client, or user+client+audience. |
| 118 |
|
| 119 |
Parameters |
| 120 |
---------- |
| 121 |
ids : typing.Optional[typing.Sequence[str]] |
| 122 |
Array of refresh token IDs to revoke. Limited to 100 at a time. |
| 123 |
|
| 124 |
user_id : typing.Optional[str] |
| 125 |
Revoke all refresh tokens for this user. |
| 126 |
|
| 127 |
client_id : typing.Optional[str] |
| 128 |
Revoke refresh tokens for this client. Must be paired with `user_id`; optionally narrowed further with `audience`. |
| 129 |
|
| 130 |
audience : typing.Optional[str] |
| 131 |
Resource server identifier (audience) to scope the revocation. Must be used with both `user_id` and `client_id`. |
| 132 |
|
| 133 |
request_options : typing.Optional[RequestOptions] |
| 134 |
Request-specific configuration. |
| 135 |
|
| 136 |
Returns |
| 137 |
------- |
| 138 |
None |
| 139 |
|
| 140 |
Examples |
| 141 |
-------- |
| 142 |
from auth0 import Auth0 |
| 143 |
|
| 144 |
client = Auth0( |
| 145 |
token="YOUR_TOKEN", |
| 146 |
) |
| 147 |
client.refresh_tokens.revoke() |
| 148 |
""" |
| 149 |
_response = self._raw_client.revoke( |
| 150 |
ids=ids, user_id=user_id, client_id=client_id, audience=audience, request_options=request_options |
| 151 |
) |
| 152 |
return _response.data |
| 153 |
|
| 154 |
def get( |
| 155 |
self, id: str, *, request_options: typing.Optional[RequestOptions] = None |
| 156 |
) -> GetRefreshTokenResponseContent: |
| 157 |
""" |
| 158 |
Retrieve refresh token information. |
| 159 |
|
| 160 |
Parameters |
| 161 |
---------- |
| 162 |
id : str |
| 163 |
ID refresh token to retrieve |
| 164 |
|
| 165 |
request_options : typing.Optional[RequestOptions] |
| 166 |
Request-specific configuration. |
| 167 |
|
| 168 |
Returns |
| 169 |
------- |
| 170 |
GetRefreshTokenResponseContent |
| 171 |
The refresh token was retrieved |
| 172 |
|
| 173 |
Examples |
| 174 |
-------- |
| 175 |
from auth0 import Auth0 |
| 176 |
|
| 177 |
client = Auth0( |
| 178 |
token="YOUR_TOKEN", |
| 179 |
) |
| 180 |
client.refresh_tokens.get( |
| 181 |
id="id", |
| 182 |
) |
| 183 |
""" |
| 184 |
_response = self._raw_client.get(id, request_options=request_options) |
| 185 |
return _response.data |
| 186 |
|
| 187 |
def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: |
| 188 |
""" |
| 189 |
Delete a refresh token by its ID. |
| 190 |
|
| 191 |
Parameters |
| 192 |
---------- |
| 193 |
id : str |
| 194 |
ID of the refresh token to delete. |
| 195 |
|
| 196 |
request_options : typing.Optional[RequestOptions] |
| 197 |
Request-specific configuration. |
| 198 |
|
| 199 |
Returns |
| 200 |
------- |
| 201 |
None |
| 202 |
|
| 203 |
Examples |
| 204 |
-------- |
| 205 |
from auth0 import Auth0 |
| 206 |
|
| 207 |
client = Auth0( |
| 208 |
token="YOUR_TOKEN", |
| 209 |
) |
| 210 |
client.refresh_tokens.delete( |
| 211 |
id="id", |
| 212 |
) |
| 213 |
""" |
| 214 |
_response = self._raw_client.delete(id, request_options=request_options) |
| 215 |
return _response.data |
| 216 |
|
| 217 |
def update( |
| 218 |
self, |
| 219 |
id: str, |
| 220 |
*, |
| 221 |
refresh_token_metadata: typing.Optional[RefreshTokenMetadata] = OMIT, |
| 222 |
request_options: typing.Optional[RequestOptions] = None, |
| 223 |
) -> UpdateRefreshTokenResponseContent: |
| 224 |
""" |
| 225 |
Update a refresh token by its ID. |
| 226 |
|
| 227 |
Parameters |
| 228 |
---------- |
| 229 |
id : str |
| 230 |
ID of the refresh token to update. |
| 231 |
|
| 232 |
refresh_token_metadata : typing.Optional[RefreshTokenMetadata] |
| 233 |
Metadata associated with the refresh token. Pass null or {} to remove all metadata. |
| 234 |
|
| 235 |
request_options : typing.Optional[RequestOptions] |
| 236 |
Request-specific configuration. |
| 237 |
|
| 238 |
Returns |
| 239 |
------- |
| 240 |
UpdateRefreshTokenResponseContent |
| 241 |
Refresh token successfully updated. |
| 242 |
|
| 243 |
Examples |
| 244 |
-------- |
| 245 |
from auth0 import Auth0 |
| 246 |
|
| 247 |
client = Auth0( |
| 248 |
token="YOUR_TOKEN", |
| 249 |
) |
| 250 |
client.refresh_tokens.update( |
| 251 |
id="id", |
| 252 |
) |
| 253 |
""" |
| 254 |
_response = self._raw_client.update( |
| 255 |
id, refresh_token_metadata=refresh_token_metadata, request_options=request_options |
| 256 |
) |
| 257 |
return _response.data |
| 258 |
|
| 259 |
|
| 260 |
class AsyncRefreshTokensClient: |
| 261 |
def __init__(self, *, client_wrapper: AsyncClientWrapper): |
| 262 |
self._raw_client = AsyncRawRefreshTokensClient(client_wrapper=client_wrapper) |
| 263 |
|
| 264 |
@property |
| 265 |
def with_raw_response(self) -> AsyncRawRefreshTokensClient: |
| 266 |
""" |
| 267 |
Retrieves a raw implementation of this client that returns raw responses. |
| 268 |
|
| 269 |
Returns |
| 270 |
------- |
| 271 |
AsyncRawRefreshTokensClient |
| 272 |
""" |
| 273 |
return self._raw_client |
| 274 |
|
| 275 |
async def list( |
| 276 |
self, |
| 277 |
*, |
| 278 |
user_id: str, |
| 279 |
client_id: typing.Optional[str] = None, |
| 280 |
from_: typing.Optional[str] = None, |
| 281 |
take: typing.Optional[int] = 50, |
| 282 |
fields: typing.Optional[str] = None, |
| 283 |
include_fields: typing.Optional[bool] = None, |
| 284 |
request_options: typing.Optional[RequestOptions] = None, |
| 285 |
) -> AsyncPager[RefreshTokenResponseContent, GetRefreshTokensPaginatedResponseContent]: |
| 286 |
""" |
| 287 |
Retrieve a paginated list of refresh tokens for a specific user, with optional filtering by client ID. Results are sorted by credential_id ascending. |
| 288 |
|
| 289 |
Parameters |
| 290 |
---------- |
| 291 |
user_id : str |
| 292 |
ID of the user whose refresh tokens to retrieve. Required. |
| 293 |
|
| 294 |
client_id : typing.Optional[str] |
| 295 |
Filter results by client ID. Only valid when user_id is provided. |
| 296 |
|
| 297 |
from_ : typing.Optional[str] |
| 298 |
An opaque cursor from which to start the selection (exclusive). Expires after 24 hours. Obtained from the next property of a previous response. |
| 299 |
|
| 300 |
take : typing.Optional[int] |
| 301 |
Number of results per page. Defaults to 50. |
| 302 |
|
| 303 |
fields : typing.Optional[str] |
| 304 |
Comma-separated list of fields to include or exclude (based on value provided for include_fields) in the result. Leave empty to retrieve all fields. |
| 305 |
|
| 306 |
include_fields : typing.Optional[bool] |
| 307 |
Whether specified fields are to be included (true) or excluded (false). |
| 308 |
|
| 309 |
request_options : typing.Optional[RequestOptions] |
| 310 |
Request-specific configuration. |
| 311 |
|
| 312 |
Returns |
| 313 |
------- |
| 314 |
AsyncPager[RefreshTokenResponseContent, GetRefreshTokensPaginatedResponseContent] |
| 315 |
The refresh tokens were retrieved. |
| 316 |
|
| 317 |
Examples |
| 318 |
-------- |
| 319 |
import asyncio |
| 320 |
|
| 321 |
from auth0 import AsyncAuth0 |
| 322 |
|
| 323 |
client = AsyncAuth0( |
| 324 |
token="YOUR_TOKEN", |
| 325 |
) |
| 326 |
|
| 327 |
|
| 328 |
async def main() -> None: |
| 329 |
response = await client.refresh_tokens.list( |
| 330 |
user_id="user_id", |
| 331 |
client_id="client_id", |
| 332 |
from_="from", |
| 333 |
take=1, |
| 334 |
fields="fields", |
| 335 |
include_fields=True, |
| 336 |
) |
| 337 |
async for item in response: |
| 338 |
yield item |
| 339 |
|
| 340 |
# alternatively, you can paginate page-by-page |
| 341 |
async for page in response.iter_pages(): |
| 342 |
yield page |
| 343 |
|
| 344 |
|
| 345 |
asyncio.run(main()) |
| 346 |
""" |
| 347 |
return await self._raw_client.list( |
| 348 |
user_id=user_id, |
| 349 |
client_id=client_id, |
| 350 |
from_=from_, |
| 351 |
take=take, |
| 352 |
fields=fields, |
| 353 |
include_fields=include_fields, |
| 354 |
request_options=request_options, |
| 355 |
) |
| 356 |
|
| 357 |
async def revoke( |
| 358 |
self, |
| 359 |
*, |
| 360 |
ids: typing.Optional[typing.Sequence[str]] = OMIT, |
| 361 |
user_id: typing.Optional[str] = OMIT, |
| 362 |
client_id: typing.Optional[str] = OMIT, |
| 363 |
audience: typing.Optional[str] = OMIT, |
| 364 |
request_options: typing.Optional[RequestOptions] = None, |
| 365 |
) -> None: |
| 366 |
""" |
| 367 |
Revoke refresh tokens in bulk by ID list, user, user+client, or user+client+audience. |
| 368 |
|
| 369 |
Parameters |
| 370 |
---------- |
| 371 |
ids : typing.Optional[typing.Sequence[str]] |
| 372 |
Array of refresh token IDs to revoke. Limited to 100 at a time. |
| 373 |
|
| 374 |
user_id : typing.Optional[str] |
| 375 |
Revoke all refresh tokens for this user. |
| 376 |
|
| 377 |
client_id : typing.Optional[str] |
| 378 |
Revoke refresh tokens for this client. Must be paired with `user_id`; optionally narrowed further with `audience`. |
| 379 |
|
| 380 |
audience : typing.Optional[str] |
| 381 |
Resource server identifier (audience) to scope the revocation. Must be used with both `user_id` and `client_id`. |
| 382 |
|
| 383 |
request_options : typing.Optional[RequestOptions] |
| 384 |
Request-specific configuration. |
| 385 |
|
| 386 |
Returns |
| 387 |
------- |
| 388 |
None |
| 389 |
|
| 390 |
Examples |
| 391 |
-------- |
| 392 |
import asyncio |
| 393 |
|
| 394 |
from auth0 import AsyncAuth0 |
| 395 |
|
| 396 |
client = AsyncAuth0( |
| 397 |
token="YOUR_TOKEN", |
| 398 |
) |
| 399 |
|
| 400 |
|
| 401 |
async def main() -> None: |
| 402 |
await client.refresh_tokens.revoke() |
| 403 |
|
| 404 |
|
| 405 |
asyncio.run(main()) |
| 406 |
""" |
| 407 |
_response = await self._raw_client.revoke( |
| 408 |
ids=ids, user_id=user_id, client_id=client_id, audience=audience, request_options=request_options |
| 409 |
) |
| 410 |
return _response.data |
| 411 |
|
| 412 |
async def get( |
| 413 |
self, id: str, *, request_options: typing.Optional[RequestOptions] = None |
| 414 |
) -> GetRefreshTokenResponseContent: |
| 415 |
""" |
| 416 |
Retrieve refresh token information. |
| 417 |
|
| 418 |
Parameters |
| 419 |
---------- |
| 420 |
id : str |
| 421 |
ID refresh token to retrieve |
| 422 |
|
| 423 |
request_options : typing.Optional[RequestOptions] |
| 424 |
Request-specific configuration. |
| 425 |
|
| 426 |
Returns |
| 427 |
------- |
| 428 |
GetRefreshTokenResponseContent |
| 429 |
The refresh token was retrieved |
| 430 |
|
| 431 |
Examples |
| 432 |
-------- |
| 433 |
import asyncio |
| 434 |
|
| 435 |
from auth0 import AsyncAuth0 |
| 436 |
|
| 437 |
client = AsyncAuth0( |
| 438 |
token="YOUR_TOKEN", |
| 439 |
) |
| 440 |
|
| 441 |
|
| 442 |
async def main() -> None: |
| 443 |
await client.refresh_tokens.get( |
| 444 |
id="id", |
| 445 |
) |
| 446 |
|
| 447 |
|
| 448 |
asyncio.run(main()) |
| 449 |
""" |
| 450 |
_response = await self._raw_client.get(id, request_options=request_options) |
| 451 |
return _response.data |
| 452 |
|
| 453 |
async def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: |
| 454 |
""" |
| 455 |
Delete a refresh token by its ID. |
| 456 |
|
| 457 |
Parameters |
| 458 |
---------- |
| 459 |
id : str |
| 460 |
ID of the refresh token to delete. |
| 461 |
|
| 462 |
request_options : typing.Optional[RequestOptions] |
| 463 |
Request-specific configuration. |
| 464 |
|
| 465 |
Returns |
| 466 |
------- |
| 467 |
None |
| 468 |
|
| 469 |
Examples |
| 470 |
-------- |
| 471 |
import asyncio |
| 472 |
|
| 473 |
from auth0 import AsyncAuth0 |
| 474 |
|
| 475 |
client = AsyncAuth0( |
| 476 |
token="YOUR_TOKEN", |
| 477 |
) |
| 478 |
|
| 479 |
|
| 480 |
async def main() -> None: |
| 481 |
await client.refresh_tokens.delete( |
| 482 |
id="id", |
| 483 |
) |
| 484 |
|
| 485 |
|
| 486 |
asyncio.run(main()) |
| 487 |
""" |
| 488 |
_response = await self._raw_client.delete(id, request_options=request_options) |
| 489 |
return _response.data |
| 490 |
|
| 491 |
async def update( |
| 492 |
self, |
| 493 |
id: str, |
| 494 |
*, |
| 495 |
refresh_token_metadata: typing.Optional[RefreshTokenMetadata] = OMIT, |
| 496 |
request_options: typing.Optional[RequestOptions] = None, |
| 497 |
) -> UpdateRefreshTokenResponseContent: |
| 498 |
""" |
| 499 |
Update a refresh token by its ID. |
| 500 |
|
| 501 |
Parameters |
| 502 |
---------- |
| 503 |
id : str |
| 504 |
ID of the refresh token to update. |
| 505 |
|
| 506 |
refresh_token_metadata : typing.Optional[RefreshTokenMetadata] |
| 507 |
Metadata associated with the refresh token. Pass null or {} to remove all metadata. |
| 508 |
|
| 509 |
request_options : typing.Optional[RequestOptions] |
| 510 |
Request-specific configuration. |
| 511 |
|
| 512 |
Returns |
| 513 |
------- |
| 514 |
UpdateRefreshTokenResponseContent |
| 515 |
Refresh token successfully updated. |
| 516 |
|
| 517 |
Examples |
| 518 |
-------- |
| 519 |
import asyncio |
| 520 |
|
| 521 |
from auth0 import AsyncAuth0 |
| 522 |
|
| 523 |
client = AsyncAuth0( |
| 524 |
token="YOUR_TOKEN", |
| 525 |
) |
| 526 |
|
| 527 |
|
| 528 |
async def main() -> None: |
| 529 |
await client.refresh_tokens.update( |
| 530 |
id="id", |
| 531 |
) |
| 532 |
|
| 533 |
|
| 534 |
asyncio.run(main()) |
| 535 |
""" |
| 536 |
_response = await self._raw_client.update( |
| 537 |
id, refresh_token_metadata=refresh_token_metadata, request_options=request_options |
| 538 |
) |
| 539 |
return _response.data |