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