Services or capabilities described in AWS documentation might vary by Region. To see the differences applicable to the AWS European Sovereign Cloud Region, see the AWS European Sovereign Cloud User Guide.Use DescribeTermsByClient with an AWS SDK
The following code example shows how to use DescribeTermsByClient.
Action examples are code excerpts from larger programs and must be run in context. You can see this action in
context in the following code example:
- Python
-
- SDK for Python (Boto3)
-
def describe_terms_by_client(
self, user_pool_id: str, client_id: str, terms_name: str
) -> dict[str, Any]:
"""
Looks up a Terms document associated with an app client by client ID,
user pool ID, and terms name.
:param user_pool_id: The ID of the user pool that contains the Terms documents.
:param client_id: The ID of the app client associated with the Terms.
:param terms_name: The name of the terms document ('terms-of-use' or
'privacy-policy').
:return: A dictionary with the Terms document details.
"""
try:
response = self.cognito_idp_client.describe_terms_by_client(
UserPoolId=user_pool_id,
ClientId=client_id,
TermsName=terms_name,
)
terms = response.get("Terms", dict())
logger.info(
"Described terms '%s' for client %s in user pool %s.",
terms_name,
client_id,
user_pool_id,
)
return terms
except ClientError as err:
if err.response["Error"]["Code"] == "ResourceNotFoundException":
logger.error(
"No terms documents found for client %s, user pool %s, "
"and terms name '%s'.",
client_id,
user_pool_id,
terms_name,
)
raise
For a complete list of AWS SDK developer guides and code examples, see
Using this service with an AWS SDK.
This topic also includes information about getting started and details about previous SDK versions.