request method
Requests authorization code via Chrome Custom Tabs
(on Android) and ASWebAuthenticationSession
(on iOS).
Implementation
Future<String> request(
{String? clientId,
String? redirectUri,
List<Prompt>? prompts,
List<String>? scopes}) async {
final finalRedirectUri = redirectUri ?? "kakao${_platformKey()}://oauth";
final params = {
"client_id": clientId ?? _platformKey(),
"redirect_uri": finalRedirectUri,
"response_type": "code",
"approval_type": "individual",
"scope": scopes == null ? null : scopes.join(" "),
"prompt": prompts == null
? null
: describeEnum(prompts.join(" ")).toLowerCase(),
"ka": await KakaoContext.kaHeader
};
params.removeWhere((k, v) => v == null);
final url = Uri.https(KakaoContext.hosts.kauth, "/oauth/authorize", params);
final authCode = await launchBrowserTab(url, redirectUri: finalRedirectUri);
return _parseCode(authCode);
}