getOAuthAuthorization method

  1. @override
Future<Map> getOAuthAuthorization(
  1. String token,
  2. String clientId,
  3. String redirectUri,
  4. String responseType,
  5. String scope,
  6. String? codeChallenge,
  7. String? codeChallengeMethod,
  8. String? state,
)
override

Implementation

@override
Future<Map> getOAuthAuthorization(
    String token,
    String clientId,
    String redirectUri,
    String responseType,
    String scope,
    String? codeChallenge,
    String? codeChallengeMethod,
    String? state) async {
  final String baseUrl = await getBaseUrl;
  var filters = [];
  var prefixes = [];

  filters.add(clientId);
  prefixes.add("client_id=");
  filters.add(redirectUri);
  prefixes.add("redirect_uri=");
  filters.add(responseType);
  prefixes.add("response_type=");
  filters.add(scope);
  prefixes.add("scope=");
  if (codeChallenge != null) {
    filters.add(codeChallenge);
    prefixes.add("code_challenge=");
  }
  if (codeChallengeMethod != null) {
    filters.add(codeChallengeMethod);
    prefixes.add("code_challenge_method=");
  }
  if (state != null) {
    filters.add(state);
    prefixes.add("state=");
  }
  String params = addFilter(filters, prefixes);
  var url = Uri.parse("$baseUrl/oauth/authorize$params");
  var response = await http.get(
    url,
    headers: {"Authorization": "Bearer $token", "x-jwt-account-id": "string"},
  );
  var data = jsonDecode(response.body);
  //print(data);
  return data;
}