getAllTokens method
Get Access, Id and refresh token, check its response: AzureTokenResponse
Implementation
Future<AzureTokenResponse?> getAllTokens({
required String redirectUri,
required String clientId,
required String authCode,
required String providedScopes,
required String userFlowName,
required String tenantBaseUrl,
String grantType = Constants.defaultGrantType,
}) async {
final uri = Uri.parse(
"$tenantBaseUrl/$userFlowName/${Constants.userGetTokenUrlEnding}");
final response = await http.post(uri, body: {
'scope': providedScopes,
'grant_type': grantType,
'code': authCode,
'client_id': clientId,
'code_verifier': pkcePair.codeVerifier,
'redirect_uri': redirectUri,
}, headers: {
"Content-Type": _formUrlEncodedContentType
});
if (response.statusCode == 200) {
final body = jsonDecode(response.body);
return AzureTokenResponse.fromJson(body);
} else {
return null;
}
}