在AWS Cognito中,Userpool是一组用户组件,而App则是这些用户组件的客户端。App是用来提供用户认证和授权的应用程序。在Userpool中创建App后,您可以使用App ID和App密钥来调用Cognito API来集成应用程序,并以编程方式管理用户池。以下是使用AWS SDK进行的示例代码:
import boto3
client = boto3.client('cognito-idp')
response = client.create_user_pool_client(
UserPoolId='string',
ClientName='string',
GenerateSecret=True|False,
RefreshTokenValidity=123,
ReadAttributes=[
'string',
],
WriteAttributes=[
'string',
],
ExplicitAuthFlows=[
'ADMIN_NO_SRP_AUTH'|'CUSTOM_AUTH_FLOW_ONLY'|'USER_PASSWORD_AUTH'|'ALLOW_ADMIN_USER_PASSWORD_AUTH'|'ALLOW_CUSTOM_AUTH'|'ALLOW_USER_PASSWORD_AUTH',
],
SupportedIdentityProviders=[
'string',
],
CallbackURLs=[
'string',
],
LogoutURLs=[
'string',
],
DefaultRedirectURI='string',
AllowedOAuthFlows=[
'code'|'implicit'|'client_credentials',
],
AllowedOAuthScopes=[
'string',
],
AllowedOAuthFlowsUserPoolClient=True|False,
AnalyticsConfiguration={
'ApplicationId': 'string',
'RoleArn': 'string',
'ExternalId': 'string',
'UserDataShared': True|False
},
PreventUserExistenceErrors='LEGACY'|'ENABLED'|'DISABLED'
)
print(response)
此代码将创建一个新的Userpool客户端并返回响应。您可以使用响应中列出的App ID和App密钥来管理Userpool中的App。