Skip to content
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

Feat/#13 카카오 로그인 기능 설정 #28

Merged
merged 4 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ dependencies {
implementation(libs.play.service.auth)
implementation(libs.dagger.hilt)
kapt(libs.dagger.hilt.compiler)

implementation(libs.kakao.login)
}

kapt {
Expand Down
10 changes: 9 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,12 @@

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile

-keep class com.kakao.sdk.**.model.* { <fields>; }
-keep class * extends com.google.gson.TypeAdapter

# https://github.com/square/okhttp/pull/6792
-dontwarn org.bouncycastle.jsse.**
-dontwarn org.conscrypt.*
-dontwarn org.openjsse.**
14 changes: 14 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".core.OworiApplication"
android:allowBackup="true"
Expand All @@ -25,6 +27,18 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<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" />

<data android:host="oauth"
android:scheme="kakao6c28960f69d4c7f00043b02d890dd6e0" />
</intent-filter>
</activity>
</application>

</manifest>
5 changes: 5 additions & 0 deletions app/src/main/java/com/owori/android/auth/data/AuthProvider.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.owori.android.auth.data

enum class AuthProvider(val value: String) {
KAKAO("KAKAO"), GOOGLE("GOOGLE")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.owori.android.auth.data

data class MemberRequest (
val token: String,
val authProvider: AuthProvider
)
2 changes: 2 additions & 0 deletions app/src/main/java/com/owori/android/core/OworiApplication.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.owori.android.core

import android.app.Application
import com.kakao.sdk.common.KakaoSdk
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class OworiApplication: Application() {
override fun onCreate() {
super.onCreate()
KakaoSdk.init(this, getString(R.string.kakao_login_key))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,24 @@ class LoginFragment : BaseFragment<FragmentLoginBinding, LoginViewModel>(R.layou
}
}

private fun startKakaoLogin() {
if (userApiClient.isKakaoTalkLoginAvailable(requireActivity().applicationContext)) {
userApiClient.loginWithKakaoTalk(requireActivity().applicationContext) { token, error ->
if (error != null) {
Log.e(ContentValues.TAG, "Failed To Kakao Login", error)
if (error is ClientError && error.reason == ClientErrorCause.Cancelled) {
return@loginWithKakaoTalk
}
userApiClient.loginWithKakaoAccount(requireActivity().applicationContext, callback = callback)
} else if (token != null) {
Log.i(ContentValues.TAG, "Success to Kakao Login ${token.accessToken}")
}
}
} else {
userApiClient.loginWithKakaoAccount(requireActivity().applicationContext, callback = callback)
}
}

private fun initCustomOnBackPressed() {
requireActivity().onBackPressedDispatcher.addCallback(this) {
requireActivity().finish()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ class LoginViewModel @Inject constructor() : BaseViewModel() {
fun onClickGoogleLogin() {
_callGoogleLogin.call()
}


}
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@
<string name="kakao_login">카카오 로그인</string>
<string name="apple_login">Apple로 로그인</string>

<!-- key -->
<string name="kakao_login_key">6c28960f69d4c7f00043b02d890dd6e0</string>

</resources>
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ google-services = "4.3.15"
play-service-auth = "20.7.0"
dagger-hilt = "2.44"
hilt-compiler = "2.44"
kakao-login = "2.17.0"

[libraries]
core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "core-ktx" }
Expand Down Expand Up @@ -72,6 +73,7 @@ firebase-auth = { group = "com.google.firebase", name = "firebase-auth-ktx" }
play-service-auth = { group = "com.google.android.gms", name = "play-services-auth", version.ref = "play-service-auth" }
dagger-hilt = { group = "com.google.dagger", name = "hilt-android", version.ref = "dagger-hilt" }
dagger-hilt-compiler = { group = "com.google.dagger", name = "hilt-compiler", version.ref = "hilt-compiler" }
kakao-login = { group = "com.kakao.sdk", name = "v2-user", version.ref = "kakao-login" }

[plugins]
androidApplication = { id = "com.android.application", version.ref = "agp" }
Expand Down
8 changes: 8 additions & 0 deletions local.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Tue Dec 19 00:06:14 KST 2023
sdk.dir=/Users/mindaein/Library/Android/sdk
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven(url = "https://devrepo.kakao.com/nexus/content/groups/public/")
}
}

Expand Down