createResourceServer method
Future<CreateResourceServerResponse>
createResourceServer({
- required String identifier,
- required String name,
- required String userPoolId,
- List<
ResourceServerScopeType> ? scopes,
Creates a new OAuth2.0 resource server and defines custom scopes in it.
May throw InvalidParameterException. May throw ResourceNotFoundException. May throw NotAuthorizedException. May throw TooManyRequestsException. May throw LimitExceededException. May throw InternalErrorException.
Parameter identifier
:
A unique resource server identifier for the resource server. This could be
an HTTPS endpoint where the resource server is located. For example,
https://my-weather-api.example.com
.
Parameter name
:
A friendly name for the resource server.
Parameter userPoolId
:
The user pool ID for the user pool.
Parameter scopes
:
A list of scopes. Each scope is map, where the keys are name
and description
.
Implementation
Future<CreateResourceServerResponse> createResourceServer({
required String identifier,
required String name,
required String userPoolId,
List<ResourceServerScopeType>? scopes,
}) async {
ArgumentError.checkNotNull(identifier, 'identifier');
_s.validateStringLength(
'identifier',
identifier,
1,
256,
isRequired: true,
);
ArgumentError.checkNotNull(name, 'name');
_s.validateStringLength(
'name',
name,
1,
256,
isRequired: true,
);
ArgumentError.checkNotNull(userPoolId, 'userPoolId');
_s.validateStringLength(
'userPoolId',
userPoolId,
1,
55,
isRequired: true,
);
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'AWSCognitoIdentityProviderService.CreateResourceServer'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'Identifier': identifier,
'Name': name,
'UserPoolId': userPoolId,
if (scopes != null) 'Scopes': scopes,
},
);
return CreateResourceServerResponse.fromJson(jsonResponse.body);
}