requestWithAgt method

Future<String> requestWithAgt(
  1. List<String> scopes, {
  2. String? clientId,
  3. String? redirectUri,
})

Requests authorization code with current access token.

User should be logged in in order to call this method.

Implementation

Future<String> requestWithAgt(List<String> scopes,
    {String? clientId, String? redirectUri}) async {
  final agt = await _kauthApi.agt();
  final finalRedirectUri = redirectUri ?? "kakao${_platformKey()}://oauth";
  final params = {
    "client_id": clientId ?? _platformKey(),
    "redirect_uri": finalRedirectUri,
    "response_type": "code",
    "agt": agt,
    "scope": scopes.length == 0 ? null : scopes.join(" "),
    "ka": await KakaoContext.kaHeader
  };
  params.removeWhere((k, v) => v == null);
  final url = Uri.https(KakaoContext.hosts.kauth, "/oauth/authorize", params);
  return _parseCode(
      await launchBrowserTab(url, redirectUri: finalRedirectUri));
}