get_resource_oauth2_token
¶
get_resource_oauth2_token(
workload_identity_token: WorkloadIdentityTokenType,
resource_credential_provider_name: CredentialProviderName,
scopes: ScopesListType,
oauth2_flow: Oauth2FlowType,
*,
config_overrides: Optional[BedrockAgentCoreClientConfig] = None,
session_uri: Optional[RequestUri] = None,
resource_oauth2_return_url: Optional[ResourceOauth2ReturnUrlType] = None,
force_authentication: Optional[bool] = None,
custom_parameters: Optional[CustomRequestParametersType] = None,
custom_state: Optional[State] = None,
resources: Optional[ResourcesListType] = None,
audiences: Optional[AudiencesListType] = None,
) -> GetResourceOauth2TokenResponse
Returns the OAuth 2.0 token of the provided resource.
Parameters:
-
workload_identity_token(WorkloadIdentityTokenType) –The identity token of the workload from which you want to retrieve the OAuth2 token.
-
resource_credential_provider_name(CredentialProviderName) –The name of the resource's credential provider.
-
scopes(ScopesListType) –The OAuth scopes being requested.
-
oauth2_flow(Oauth2FlowType) –The type of flow to be performed.
-
session_uri(Optional[RequestUri], default:None) –Unique identifier for the user's authentication session for retrieving OAuth2 tokens. This ID tracks the authorization flow state across multiple requests and responses during the OAuth2 authentication process.
-
resource_oauth2_return_url(Optional[ResourceOauth2ReturnUrlType], default:None) –The callback URL to redirect to after the OAuth 2.0 token retrieval is complete. This URL must be one of the provided URLs configured for the workload identity.
-
force_authentication(Optional[bool], default:None) –Indicates whether to always initiate a new three-legged OAuth (3LO) flow, regardless of any existing session.
-
custom_parameters(Optional[CustomRequestParametersType], default:None) –A map of custom parameters to include in the authorization request to the resource credential provider. These parameters are in addition to the standard OAuth 2.0 flow parameters, and will not override them.
-
custom_state(Optional[State], default:None) –An opaque string that will be sent back to the callback URL provided in resourceOauth2ReturnUrl. This state should be used to protect the callback URL of your application against CSRF attacks by ensuring the response corresponds to the original request.
-
resources(Optional[ResourcesListType], default:None) –The resources to include in the token request. These are used to specify the target resources for which the OAuth2 token is being requested.
-
audiences(Optional[AudiencesListType], default:None) –The audiences to include in the token request. These are used to specify the intended recipients of the OAuth2 token.
Raises:
-
AccessDeniedException–The exception that occurs when you do not have sufficient permissions to perform an action. Verify that your IAM policy includes the necessary permissions for the operation you are trying to perform.
-
InternalServerException–The exception that occurs when the service encounters an unexpected internal error. This is a temporary condition that will resolve itself with retries. We recommend implementing exponential backoff retry logic in your application.
-
ResourceNotFoundException–The exception that occurs when the specified resource does not exist. This can happen when using an invalid identifier or when trying to access a resource that has been deleted.
-
ThrottlingException–The exception that occurs when the request was denied due to request throttling. This happens when you exceed the allowed request rate for an operation. Reduce the frequency of requests or implement exponential backoff retry logic in your application.
-
UnauthorizedException–This exception is thrown when the JWT bearer token is invalid or not found for OAuth bearer token based access
-
ValidationException–The exception that occurs when the input fails to satisfy the constraints specified by the service. Check the error message for details about which input parameter is invalid and correct your request.
-
UnknownServiceError–The service returned an error code this client does not model.
Source code in docs_src/capo_bedrock_agentcore/_services/bedrock_agent_core.py
596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 | |