문의 시 사용하시는 SDK 버전 정보와 플랫폼(Android / iOS)를 알려주세요.
요약
AuthCodeClient 를 이용하여 로그인 시 첫 로그인은 문제 없이 작동 하나, 회원 탈퇴, 카카오 계정 연동 해제(카카오톡 어플 내에서) 후 재 로그인 시 null check 오류 발생
UserApi 로 로그인 시 문제 발생 하지 않음
두 객체에 어떤 차이가 있기에 이런 차이를 보이는지 문의 드립니다.
sdk
kakao_flutter_sdk: ^0.9.0
flutter docter
[✓] Flutter (Channel stable, 2.5.1, on macOS 11.6 20G165 darwin-arm, locale ko-KR)
• Flutter version 2.5.1 at /Users/choijunho/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision ffb2ecea52 (3달 전), 2021-09-17 15:26:33 -0400
• Engine revision b3af521a05
• Dart version 2.14.2
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/choijunho/Library/Android/sdk
• Platform android-31, build-tools 31.0.0
• Java binary at: /Users/choijunho/Downloads/Android Studio arm.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 13.1, Build version 13A1030d
• CocoaPods version 1.11.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
[✓] Android Studio (version 2020.3)
• Android Studio at /Users/choijunho/Downloads/Android Studio arm.app/Contents
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
[✓] VS Code (version 1.62.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.28.0
[✓] Connected device (2 available)
• 정다희의 iPhone 8 (mobile) • 13050b4506147e639956cd30fd2534d7e751ac6a • ios • iOS 14.4.2 18D70
코드정보
Future<myUser.User?> login(bool installed) async {
try {
///정상 작동 코드
final code = installed ? await UserApi.instance.loginWithKakaoTalk() : await UserApi.instance.loginWithKakaoAccount();
///아래 코드에서 유저 탈퇴, 계정연동 해제 후 다시 AuthCodeClient 로 접근 시 로그인 창이 뜨지 않음
///---Exception: null check operator used on a null value---
// final client = AuthCodeClient.instance;
// var code = installed ? await client.requestWithTalk() : await client.requestWithAgt(["account_email", "talk_message", "profile_nickname", "profile_image"]);
await _issueAccessToken(token: code).then((user) {
_user = user;
Log.d(user);
});
return _user;
} on KakaoAuthException catch (e) {
Log.d("카카오 로그인 오류 Auth $e");
return null;
} on KakaoClientException catch (e) {
Log.d("카카오 로그인 오류 Client $e");
return null;
}
}
null check operator used on a null value
in auth_code.dart
Future<String> requestWithAgt(List<String> scopes,
{String? clientId, String? redirectUri}) async {
final agt = await _kauthApi.agt(); ------------------------> ///null
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));
}
in auth_api.dart
/// Issues temporary agt (access token-generated token), which can be used to acquire auth code.
Future<String> agt({String? clientId, String? accessToken}) async {
final tokenInfo = await _tokenManagerProvider.manager.getToken();
final data = {
"client_id": clientId ?? KakaoContext.platformClientId,
"access_token": accessToken ?? tokenInfo!.accessToken -------------------> ///null
};
return await ApiFactory.handleApiError(() async {
final response = await _dio.post("/api/agt", data: data);
return response.data["agt"];
});
}