getTokenWithPasswordGrantFlow method
Requests an Access Token to the OAuth2 endpoint using the Password Grant flow.
Implementation
Future<AccessTokenResponse> getTokenWithPasswordGrantFlow(
{required String clientId,
required String clientSecret,
List<String>? scopes,
required String username,
required String password,
httpClient}) async {
var params = <String, String>{
'grant_type': 'password',
'username': username,
'password': password
};
if (scopes != null && scopes.isNotEmpty) {
params['scope'] = serializeScopes(scopes);
}
var response = await _performAuthorizedRequest(
url: tokenUrl,
clientId: clientId,
clientSecret: clientSecret,
params: params,
httpClient: httpClient);
return http2TokenResponse(response, requestedScopes: scopes);
}