-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
카카오로 로그인 기능 추가 #323
카카오로 로그인 기능 추가 #323
Conversation
.github/workflows/cd.yml
Outdated
@@ -16,7 +16,7 @@ jobs: | |||
- name: Setup Java | |||
uses: actions/setup-java@v2 | |||
with: | |||
java-version: 17 | |||
java-version: 18 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
얘네는 왜 올리는 것?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
공식 문서에 올리라고 되어 있긴 한데... 안올려도 됐으려나..?
올리라고 되어 있다기보다는 그냥 자바 8을 사용하라고만 되어 있긴 해
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
안드로이드 문서를 읽었을 때는 그냥 그게 좋으니까 18을 쓰라는 느낌이긴 하네
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
앜ㅋㅋ 공식문서에서는 JAVA 8 쓰라는 거 아니야? 저건 8이 아니라 18이야
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JavaVersion.VERSION_18 === 자바 18
JavaVersion.VERSION_1_8 === 자바 1.8 === 자바 8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아아니 어쩐지 제목에는 8이라고 해놓고 1_8이라고 했길래
뭐지 오타인가..? 싶었네
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그럼 올리지 않아도 되는거를 그토록 삽질하고 있었다고...?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요것도 롤백하기
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
롤백 2e5b343
app/build.gradle.kts
Outdated
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
sourceCompatibility = JavaVersion.VERSION_18 | ||
targetCompatibility = JavaVersion.VERSION_18 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
얘는 왜 올리는거야 (2)
storage.prefKeyUserId.update(response.userId.toOptional()) | ||
storage.accessToken.update(response.token) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요거는 다른 PR에서 별도로 하자
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ㅋㅋㅋㅋ 네이밍만 바꾼거라 여기서 슥 했는데 이걸 눈치챘네
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
롤백 bdce3fe
import com.wafflestudio.snutt2.R | ||
import com.wafflestudio.snutt2.lib.android.toast | ||
|
||
class AuthCodeHandlerActivity : AppCompatActivity() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SDK 문서 안 읽어본 사람도 이 PR을 보고 이해할 수 있게, 왜 새 액티비티가 필요했는지 + SDK에서 이걸 어떻게 쓰는지 본문에 설명 적어주면 좋을듯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오프라인 리뷰 -> 필요 없다!
if (UserApiClient.instance.isKakaoTalkLoginAvailable(this)) { | ||
UserApiClient.instance.loginWithKakaoTalk(this) { token, error -> | ||
if (error != null) { | ||
if (error is ClientError && error.reason == ClientErrorCause.Cancelled) { | ||
this.toast(getString(R.string.sign_in_kakao_failed_cancelled)) | ||
} else if (error is AuthError && error.reason == AuthErrorCause.AccessDenied) { | ||
this.toast(getString(R.string.sign_in_kakao_failed_cancelled)) | ||
} else { | ||
// 카카오계정으로 로그인 | ||
UserApiClient.instance.loginWithKakaoAccount(context = this, callback = loginWithKakaoAccountCallback) | ||
} | ||
} else if (token == null) { | ||
this.toast(getString(R.string.sign_in_kakao_failed_unknown)) | ||
} | ||
} | ||
} else { | ||
// 카카오계정으로 로그인 | ||
UserApiClient.instance.loginWithKakaoAccount(context = this, callback = loginWithKakaoAccountCallback) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요런것도 카카오 SDK의 흐름이 어떻게 되는지 PR본문에 적어주면 좋지
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
본문 = description 인거지..?
지금 작성해볼게
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기 추가된 로직들도 동일
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고고~
<activity | ||
android:name="com.kakao.sdk.auth.AuthCodeHandlerActivity" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.VIEW" /> | ||
<category android:name="android.intent.category.DEFAULT" /> | ||
<category android:name="android.intent.category.BROWSABLE" /> | ||
|
||
<!-- Redirect URI: "kakao${NATIVE_APP_KEY}://oauth" --> | ||
<data android:host="oauth" | ||
android:scheme="@string/kakao_native_app_key_kakao" /> | ||
</intent-filter> | ||
</activity> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오프라인 리뷰 -> 이 Activity 는 카카오 SDK 꺼다! 우리가 구현하는 우리 께 아니다.
우리는 오직 이 Activity가 열릴 수 있도록 정의해주고, 이 Activity가 특정 intent scheme으로 열릴 수 있도록 intent-filter를 설정해 준다.
그러면 카카오 SDK 내부에서 context.startActivity(someIntent) 를 하면 저 카카오꺼 Activity가 열리게 된다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
뭐지 근데 아래 댓글은 왜 답글이 불가능한거지?
import com.wafflestudio.snutt2.R | ||
import com.wafflestudio.snutt2.lib.android.toast | ||
|
||
class AuthCodeHandlerActivity : AppCompatActivity() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오프라인 리뷰 -> 필요 없다!
|
||
val handleKakaoSignin: () -> Unit = { | ||
// 먼저 이전의 로그인 정보를 날림 | ||
UserApiClient.instance.unlink { logoutError -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오프라인 리뷰 -> 요건 연동해제 기능이다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
굿굿~
카카오 로그인의 흐름
이때 카카오톡이 깔려 있으면 이 인증은 자동으로 된다.
아니면 사용자가 자신의 카카오 계정을 입력해야 한다.
카카오가 제공해주는 로그인 함수들은 이 토큰의 유효성을 자동으로 검사할거고,
사용자에 대한 앱의 처리는 우리 서버가 처리할 것이다. (서버에서도 토큰의 유효성을 한번 더 검사한다)
AuthCodeHandlerActivity
그러므로, 사실 여기서 담당하는 부분은 오류가 나더라도 우리의 잘못이 아니고, 이유도 알 수 없다.
심지어 네트워크가 없는 상황도 TutorialPage에서 터지기 때문에,
여기에서 발생할 오류는 '서버와 앱이 인가 코드를 주고 받는' 신의 타이밍에 사용자가 cancel 하는 경우밖에 없다. (고 생각한다.)
심지어 토큰을 받아도 여기서 처리하지도 않는다.
그럼 이게 필요한 이유는?
TutorialPage
사실상 여기가 메인이다. 위의 AuthCodeHandlerActivity는 사용자도 모르는 사이에 내부적으로 뭔가 처리하는 느낌이라서.
handleKakaoSignin
UserApiClient.instance.unlink
로 로그인을 시도할 때마다 계정을 선택할 수 있게, 로그인 직전에 이전의 정보들을 날린다.UserApiClient.instance.isKakaoTalkLoginAvailable
로 카카오톡이 깔려있는지 판단한다.loginWithKakaoAccountCallback
에 있다.