OAuthSettings Struct
OAuth settings to configure the interaction between the app and this client.
| Source | aws-cognito/lib/user-pool-client.ts |
|---|---|
| Type last changed |
Example
ts
const pool = new cognito.UserPool(this, 'Pool');
const readOnlyScope = new cognito.ResourceServerScope({ scopeName: 'read', scopeDescription: 'Read-only access' });
const fullAccessScope = new cognito.ResourceServerScope({ scopeName: '*', scopeDescription: 'Full access' });
const userServer = pool.addResourceServer('ResourceServer', {
identifier: 'users',
scopes: [ readOnlyScope, fullAccessScope ],
});
const readOnlyClient = pool.addClient('read-only-client', {
// ...
oAuth: {
// ...
scopes: [ cognito.OAuthScope.resourceServer(userServer, readOnlyScope) ],
},
});
const fullAccessClient = pool.addClient('full-access-client', {
// ...
oAuth: {
// ...
scopes: [ cognito.OAuthScope.resourceServer(userServer, fullAccessScope) ],
},
});
python
pool = cognito.UserPool(self, "Pool")
read_only_scope = cognito.ResourceServerScope(scope_name="read", scope_description="Read-only access")
full_access_scope = cognito.ResourceServerScope(scope_name="*", scope_description="Full access")
user_server = pool.add_resource_server("ResourceServer",
identifier="users",
scopes=[read_only_scope, full_access_scope]
)
read_only_client = pool.add_client("read-only-client",
# ...
o_auth=cognito.OAuthSettings(
# ...
scopes=[cognito.OAuthScope.resource_server(user_server, read_only_scope)]
)
)
full_access_client = pool.add_client("full-access-client",
# ...
o_auth=cognito.OAuthSettings(
# ...
scopes=[cognito.OAuthScope.resource_server(user_server, full_access_scope)]
)
)
java
UserPool pool = new UserPool(this, "Pool");
ResourceServerScope readOnlyScope = ResourceServerScope.Builder.create().scopeName("read").scopeDescription("Read-only access").build();
ResourceServerScope fullAccessScope = ResourceServerScope.Builder.create().scopeName("*").scopeDescription("Full access").build();
UserPoolResourceServer userServer = pool.addResourceServer("ResourceServer", UserPoolResourceServerOptions.builder()
.identifier("users")
.scopes(List.of(readOnlyScope, fullAccessScope))
.build());
UserPoolClient readOnlyClient = pool.addClient("read-only-client", UserPoolClientOptions.builder()
// ...
.oAuth(OAuthSettings.builder()
// ...
.scopes(List.of(OAuthScope.resourceServer(userServer, readOnlyScope)))
.build())
.build());
UserPoolClient fullAccessClient = pool.addClient("full-access-client", UserPoolClientOptions.builder()
// ...
.oAuth(OAuthSettings.builder()
// ...
.scopes(List.of(OAuthScope.resourceServer(userServer, fullAccessScope)))
.build())
.build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
var pool = new UserPool(this, "Pool");
var readOnlyScope = new ResourceServerScope(new ResourceServerScopeProps { ScopeName = "read", ScopeDescription = "Read-only access" });
var fullAccessScope = new ResourceServerScope(new ResourceServerScopeProps { ScopeName = "*", ScopeDescription = "Full access" });
var userServer = pool.AddResourceServer("ResourceServer", new UserPoolResourceServerOptions {
Identifier = "users",
Scopes = new [] { readOnlyScope, fullAccessScope }
});
var readOnlyClient = pool.AddClient("read-only-client", new UserPoolClientOptions {
// ...
OAuth = new OAuthSettings {
// ...
Scopes = new [] { OAuthScope.ResourceServer(userServer, readOnlyScope) }
}
});
var fullAccessClient = pool.AddClient("full-access-client", new UserPoolClientOptions {
// ...
OAuth = new OAuthSettings {
// ...
Scopes = new [] { OAuthScope.ResourceServer(userServer, fullAccessScope) }
}
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
pool := cognito.NewUserPool(this, jsii.String("Pool"))
readOnlyScope := cognito.NewResourceServerScope(&ResourceServerScopeProps{
ScopeName: jsii.String("read"),
ScopeDescription: jsii.String("Read-only access"),
})
fullAccessScope := cognito.NewResourceServerScope(&ResourceServerScopeProps{
ScopeName: jsii.String("*"),
ScopeDescription: jsii.String("Full access"),
})
userServer := pool.addResourceServer(jsii.String("ResourceServer"), &UserPoolResourceServerOptions{
Identifier: jsii.String("users"),
Scopes: []ResourceServerScope{
readOnlyScope,
fullAccessScope,
},
})
readOnlyClient := pool.addClient(jsii.String("read-only-client"), &UserPoolClientOptions{
// ...
OAuth: &OAuthSettings{
// ...
Scopes: []OAuthScope{
cognito.OAuthScope_ResourceServer(userServer, readOnlyScope),
},
},
})
fullAccessClient := pool.addClient(jsii.String("full-access-client"), &UserPoolClientOptions{
// ...
OAuth: &OAuthSettings{
// ...
Scopes: []OAuthScope{
cognito.OAuthScope_*ResourceServer(userServer, fullAccessScope),
},
},
})
Properties
callbackUrlsoptionalstring[]callback_urlsoptionaltyping.List[str]callbackUrlsoptionalList<String>CallbackUrlsoptionalstring[]CallbackUrlsoptional*[]*string #List of allowed redirect URLs for the identity providers.
Default: ['https://example.com'] if either authorizationCodeGrant or implicitCodeGrant flows are enabled, no callback URLs otherwise.
defaultRedirectUrioptionalstringdefault_redirect_urioptionalstrdefaultRedirectUrioptionalStringDefaultRedirectUrioptionalstringDefaultRedirectUrioptional*string #The default redirect URI. Must be in the `callbackUrls` list.
Default: no default redirect URI
A redirect URI must:
- Be an absolute URI
- Be registered with the authorization server.
- Not include a fragment component.
flowsoptionalOAuthFlowsflowsoptionalOAuthFlowsflowsoptionalOAuthFlowsFlowsoptionalOAuthFlowsFlowsoptionalOAuthFlows #OAuth flows that are allowed with this client.
Default: {authorizationCodeGrant:true,implicitCodeGrant:true}
logoutUrlsoptionalstring[]logout_urlsoptionaltyping.List[str]logoutUrlsoptionalList<String>LogoutUrlsoptionalstring[]LogoutUrlsoptional*[]*string #List of allowed logout URLs for the identity providers.
Default: no logout URLs
scopesoptionalOAuthScope[]scopesoptionaltyping.List[OAuthScope]scopesoptionalList<OAuthScope>ScopesoptionalOAuthScope[]Scopesoptional*[]OAuthScope #OAuth scopes that are allowed with this client.
Default: [OAuthScope.PHONE,OAuthScope.EMAIL,OAuthScope.OPENID,OAuthScope.PROFILE,OAuthScope.COGNITO_ADMIN]