crossplatformkorea / react-native-kakao-login

react-native native module for Kakao sign in.
MIT License
358 stars 135 forks source link

Error: invalid_grant 발생 #212

Closed themore8109 closed 3 years ago

themore8109 commented 3 years ago

Version of kakao-login libraries

3.0.7

Version of react-native

0.64.0

Platforms you faced the error (IOS or Android or both?)

IOS

Expected behavior

Kakao login token값을 정상적으로 가져와야 합니다. 또는, exception을 catch할 수 있게 되어야 합니다. 또는, KOE303 invalid_grant 등 카카오의 오류 코드를 알 수 있게 되었으면 합니다.

Actual behavior

Error: invalid_grant 를 반환한다. 상세 로그는 아래와 같습니다.

[Log] 오후 12:28:43 | ModalSocialAuth | Login Start (index.bundle, line 115463) [Error] [ERROR] 28:46.929 OAuth - Error handling auth response. Error: invalid_grant (익명 함수) — index.bundle:232924 step — index.bundle:206728 (익명 함수) — index.bundle:206658 fulfilled — index.bundle:206612 tryCallOne — index.bundle:31494 (익명 함수) — index.bundle:31595 _callTimer — index.bundle:31923 _callImmediatesPass — index.bundle:31962 callImmediates — index.bundle:32179 callImmediates — index.bundle:3215 (익명 함수) — index.bundle:2994 guard — index.bundle:3198 flushedQueue — index.bundle:2993 flushedQueue invokeCallbackAndReturnFlushedQueue (익명 함수) — debuggerWorker.aca173c4.js:4:908 error reactConsoleErrorHandler (index.bundle:25430) overrideMethod (index.bundle:48520) registerError (index.bundle:80083) errorImpl (index.bundle:79990) (익명 함수) (index.bundle:79967) (익명 함수) (익명 함수) (index.bundle:200144) (익명 함수) (index.bundle:200187) (익명 함수) (index.bundle:233024) step (index.bundle:206728) (익명 함수) (index.bundle:206658) rejected (index.bundle:206620) tryCallOne (index.bundle:31494) (익명 함수) (index.bundle:31595) _callTimer (index.bundle:31923) _callImmediatesPass (index.bundle:31962) callImmediates (index.bundle:32179) callImmediates (index.bundle:3215) (익명 함수) (index.bundle:2994) guard (index.bundle:3198) flushedQueue (index.bundle:2993) flushedQueue invokeCallbackAndReturnFlushedQueue (익명 함수) (debuggerWorker.aca173c4.js:4:908)

Tested environment (Emulator? Real Device?)

Kakao가 설치 되어 있지 않은 simulator(iPhone12) 환경에서는 정상적으로 InAppBrowser(?)를 통해 정상적으로 로그인 및 토큰 정보를 가져옵니다. 또한 카카오의 연결된 서비스 관리에도 해당 App이 나타나고 있는것을 확인 하였습니다.

Kakao가 설치 되어 있는 실제 디바이스(iPhone Se2)에서는 위와 같은 에러 로그가 발생 합니다.

kakao app key는 정상적으로 입력된 것을 확인 하였습니다. image

확인 부탁 드립니다.

감사합니다.

themore8109 commented 3 years ago

제가 IOS와 Swift쪽은 잘 알지는 못하지만, KakaoDevTalk에서 아래와 같은 글을 발견 했습니다. https://devtalk.kakao.com/t/sdk/113405/3

혹시 같은 증상이 아닌가 의심되네요..

Xcode로 실행시 아래와 같은 로그도 추가로 발견 되었습니다.

2021-04-20 14:56:41.136840+0900 ...[19589:6642096] 7.10.0 - [Firebase/Analytics][I-ACS023001] Deep Link does not contain valid required params. URL params: { code = "uFDoculJHOyzNbxyHA2JL1iiWZ4QQ_TQFlKRAvhgUnHrnZjeBpNpXDlSY-Olpo4GDPeOWwo9dJkAAAF47doo2g"; } 2021-04-20 14:56:42.161962+0900 ...[19589:6641991] [javascript] '[ERROR] 56:42.161 OAuth - Error handling auth response.', [Error: invalid_grant]

themore8109 commented 3 years ago

아마도 Kakao SDK에서 손봐야 할 문제인듯 싶네요... RedirectUrl생성 하는 부분의 문제가 아닐까 의심합니다. xcode 에서 디버깅 하여 App으로의 요청과 Browser로의 요청의 차이점을 보니 아래와 같습니다.

Browser 로의 요청 finalStringUrl String "https://kauth.kakao.com/oauth/authorize?client_id=3274f6e5d81....&ka=sdk/2.4.1 sdk_type/swift os/ios-14.4 lang/ko-KR res/375x667 device/iPad origin/com.the.... app_ver/2.2&code_challenge_method=S256&redirect_uri=kakao3274f6e5d81...://oauth&code_challenge=eKNDPQ2X230cPumD5WvDy...&response_type=code"

Kakao APP 로의 요청 finalStringUrl String "kakaokompassauth://authorize?client_id=3274f....&redirect_uri=kakao3274f6e5d81...://oauth&response_type=code&headers=%7B%22KA%22:%22sdk%5C/2.4.1%20sdk_type%5C/swift%20os%5C/ios-14.4.2%20lang%5C/ko-KR%20res%5C/375x667%20device%5C/iPhone%20origin%5C/com.the...%20app_ver%5C/2.2%22%7D&params=%7B%22code_challenge_method%22:%22S256%22,%22code_challenge%22:%22Sh1v1N5sZ-UKQoLtg..."

이슈는 종료 처리 하겠습니다.