authorizeWithTalk method

Future<String> authorizeWithTalk(
  1. {String? clientId,
  2. required String redirectUri,
  3. List<Prompt>? prompts,
  4. List<String>? channelPublicId,
  5. List<String>? serviceTerms,
  6. String? codeVerifier,
  7. String? nonce,
  8. String? kauthTxId,
  9. String? stateToken,
  10. bool webPopupLogin = false}
)

사용자가 앱에 로그인할 수 있도록 사용자의 디바이스에 설치된 카카오톡을 통해 인가 코드를 요청하는 함수입니다. 인가 코드를 받을 수 있는 서버 개발이 필요합니다.

Implementation

Future<String> authorizeWithTalk({
  String? clientId,
  required String redirectUri,
  List<Prompt>? prompts,
  List<String>? channelPublicId,
  List<String>? serviceTerms,
  String? codeVerifier,
  String? nonce,
  String? kauthTxId,
  String? stateToken,
  bool webPopupLogin = false,
}) async {
  try {
    final webStateToken =
        stateToken ?? (kIsWeb ? generateRandomString(20) : null);

    var response = await _openKakaoTalk(
      clientId ?? KakaoSdk.appKey,
      redirectUri,
      channelPublicId,
      serviceTerms,
      codeVerifier,
      prompts,
      nonce,
      kauthTxId,
      stateToken: webStateToken,
      webPopupLogin: webPopupLogin,
    );

    if (kIsWeb) {
      if (webPopupLogin) {
        return response;
      }
      var params = {
        'redirect_uri': redirectUri,
        'code': response,
        'state': webStateToken
      };
      await _channel.invokeMethod('redirectForEasyLogin', params);
      return response;
    }
    return _parseCode(response);
  } catch (e) {
    SdkLog.e(e);
    rethrow;
  }
}