This is Compose Multiplatform auth library
This is Development!!
| Android | IOS | |
|---|---|---|
| google-Login | ||
| github-Login | ||
| apple-Login |
- ✅ Google Login
- ✅ Github Login
- ✅ Apple Login
- ❎ Naver Login
HelLogin is available on Maven Central. In your root project build.gradle.kts file (
or settings.gradle file) add mavenCentral() to repositories.
repositories {
mavenCentral()
}Then in your shared module add desired dependencies in commonMain. Latest
version:
sourceSets {
commonMain.dependencies {
implementation(platform("io.github.jmseb3:hellogin-bom:1.1.0"))
implementation("io.github.jmseb3:hellogin-google") //google login library
implementation("io.github.jmseb3:hellogin-github") //github login library
implementation("io.github.jmseb3:hellogin-apple") //apple login library
// or
implementation("io.github.jmseb3:hellogin-google-ui") //google login with ui library
implementation("io.github.jmseb3:hellogin-github-ui") //github login with ui library
implementation("io.github.jmseb3:hellogin-apple-ui") //apple login with ui library
}
}or use toml
[versions]
hellogin = "1.1.0"
[libraries]
hellogin-bom = { module = "io.github.jmseb3:hellogin-bom", version.ref = "hellogin" }
hellogin-google = { module = "io.github.jmseb3:hellogin-google" }
hellogin-github = { module = "io.github.jmseb3:hellogin-github" }
hellogin-apple = { module = "io.github.jmseb3:hellogin-apple" }
// OR
hellogin-google-ui = { module = "io.github.jmseb3:hellogin-google-ui" }
hellogin-github-ui = { module = "io.github.jmseb3:hellogin-github-ui" }
hellogin-apple-ui = { module = "io.github.jmseb3:hellogin-apple-ui" }
sourceSets {
commonMain.dependencies {
implementation(project.dependencies.platform(libs.hellogin.bom))
implementation(libs.hellogin.google)
implementation(libs.hellogin.github)
implementation(libs.hellogin.apple)
implementation(libs.hellogin.google.ui)
implementation(libs.hellogin.github.ui)
implementation(libs.hellogin.apple.ui)
}
}how to use this library
use HelloginContainerProvider.setContainer(this) on Activity onCreate
class AppActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
...
HelloginContainerProvider.setContainer(this)
}
}use HelloginContainerProvider.setContainer(this) on MainViewController create
fun MainViewController(): UIViewController {
return ComposeUIViewController { App() }.also {
HelloginContainerProvider.setContainer(it)
}
}don't forget Google Api console setting!!
also default setting
- plz install first
GoogleOptionProviderper platform
also IOS need
GoogeSiginSPM or pods on Your Project
class AppActivity : ComponentActivity(), OptionProviderAndroid {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
...
GoogleLoginHelper.setOptionProvider(this)
}
override fun provideGoogleIdOption(): GetGoogleIdOption {
return GetGoogleIdOption.Builder()
.setFilterByAuthorizedAccounts(false)
.setServerClientId("WEB_CLIENT_ID")
.build()
}
}use
OptionProviderAndroidbecause needGetGoogleIdOption
no need any setting for google Login
- launch
GoogleLoginHelperwith TokenResultHandler
GoogleLoginHelper.requestLogin(tokenResultHandler) //this is suspend functionif use io.github.jmseb3:hellogin-google-ui , GoogleLoginButton()
GoogleLoginButton()make Github OAuth Apps and don't forget
your GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET
also android need scheme setting .. if callback is
hellogin://loginthen
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<activity>
...
<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="login" android:scheme="hellogin" />
</intent-filter>
</activity>
</application>
</manifest>- Please install the GitHub provider in the commonMain module (or separately for each platform if needed).
internal class GitHubProvider : GithubOptionProvider {
companion object {
const val GITHUB_CLIENT_ID = "YOUR_CLIENT_ID"
const val GITHUB_CLIENT_SECRET = "YOUR_CLIENT_SECRET"
}
override fun provideLoginId(): CodeRequestData {
return CodeRequestData(
GITHUB_CLIENT_ID
)
}
override fun provideClientData(): ClientData {
return ClientData(
GITHUB_CLIENT_ID,
GITHUB_CLIENT_SECRET
)
}
override fun provideScheme(): String {
return "hellogin"
}
}@Composable
internal fun App() = AppTheme {
LaunchedEffect(true) {
GithubLoginHelper.setOptionProvider(GitHubProvider())
}
...
}class AppActivity : ComponentActivity(), OptionProviderAndroid {
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
CoroutineScope(Dispatchers.Main).launch {
intent.data?.getQueryParameter("code")?.let { code ->
// Get Token By Intent
GithubLoginHelper.requestAuth(code)
}
}
}
}- launch
GithubLoginHelperwith TokenResultHandler
GithubLoginHelper.requestLogin(tokenResultHandler) // this is suspend functionif use io.github.jmseb3:hellogin-github-ui , GithubLoginButton()
GithubLoginButton()