in lib/src/resource_owner_password_grant.dart [47:94]
Future<Client> resourceOwnerPasswordGrant(
Uri authorizationEndpoint, String username, String password,
{String? identifier,
String? secret,
Iterable<String>? scopes,
bool basicAuth = true,
CredentialsRefreshedCallback? onCredentialsRefreshed,
http.Client? httpClient,
String? delimiter,
Map<String, dynamic> Function(MediaType? contentType, String body)?
getParameters}) async {
delimiter ??= ' ';
var startTime = DateTime.now();
var body = {
'grant_type': 'password',
'username': username,
'password': password
};
var headers = <String, String>{};
if (identifier != null) {
if (basicAuth) {
headers['Authorization'] = basicAuthHeader(identifier, secret!);
} else {
body['client_id'] = identifier;
if (secret != null) body['client_secret'] = secret;
}
}
if (scopes != null && scopes.isNotEmpty) {
body['scope'] = scopes.join(delimiter);
}
httpClient ??= http.Client();
var response = await httpClient.post(authorizationEndpoint,
headers: headers, body: body);
var credentials = handleAccessTokenResponse(
response, authorizationEndpoint, startTime, scopes?.toList(), delimiter,
getParameters: getParameters);
return Client(credentials,
identifier: identifier,
secret: secret,
httpClient: httpClient,
onCredentialsRefreshed: onCredentialsRefreshed);
}