exchangeCodeForToken method

Future<Map<String, dynamic>> exchangeCodeForToken({
  1. required String code,
  2. required String flowName,
})

Implementation

Future<Map<String, dynamic>> exchangeCodeForToken({
  required String code,
  required String flowName,
}) async {
  final tokenUrl =
      "https://gichprod.ciamlogin.com/$tenantId/oauth2/v2.0/token";

  final data = {
    "grant_type": "authorization_code",
    "client_id": clientId,
    "code": code,
    "redirect_uri": redirectUri,
    "scope": scope,
    "code_verifier": _codeVerifier,
  };
  try {
    final response = await _dio.post(
      tokenUrl,
      data: data,
      options: Options(contentType: Headers.formUrlEncodedContentType),
    );
    return response.data;
  } on DioException catch (e) {
    return {"error": e};
  }
}