The license information for logo is located at the bottom of the document.
These instructions are available in their respective languages.
An Android Library that provides social login for 15 platforms within by RxJava2, Kotlin and Firebase Authentication.
This library is an improved version of @WindSekirun 's SocialLogin library. It has the following differences.
Platform | Data | Version |
---|---|---|
Disqus | id, name, email, nickname, profilePicture, accessToken | 1.0.0 |
id, name, email, profilePicture, gender, firstName, accessToken | 0.5.0 | |
Foursquare | id, name, email, firstName, gender, birthDay, profilePicture, accessToken | 1.0.0 |
Github | id, name, email, profilePicture, emailVerified, accessToken | 1.0.0 |
id, name, email, profilePicture, emailVerified | 0.5.0 | |
Kakao | id, name, email, profilePicture, thumbnailImage, ageRange, birthDay, gender, emailVerified | 0.5.0 |
Line | id, name, accessToken | 0.5.0 |
id, name, email, profilePicture, firstName, accessToken | 1.0.0 | |
Naver | id, name, email, nickname, gender, profilePicture, age, birthDay, accessToken | 0.5.0 |
Twitch | id, name, email, profilePicture, accessToken | 1.0.0 |
id, name, nickname, email, profilePicture | 0.5.0 | |
VK | id, name, email, profilePicture, nickname, firstName, birthDay | 1.0.0 |
Windows | id, name, email | 1.0.0 |
Wordpress | id, name, email, profilePicture, emailVerified, accessToken | 1.0.0 |
Yahoo | id, name | 1.0.0 |
Click on the name of each platform to move to how to apply the platform.
Add the following code to build.gradle
in the root folder.
allprojects {
repositories {
maven { url 'http://devrepo.kakao.com:8088/nexus/content/groups/public/' }
maven { url 'https://jitpack.io' }
}
}
Add the following dependencies to the build.gradle
of the module you want to use.
dependencies {
implementation 'com.github.WindSekirun:RxSocialLogin:1.2.5.4'
// androidx
implementation 'com.github.WindSekirun:RxSocialLogin:1.2.5.4-androidx'
// RxJava
implementation 'io.reactivex.rxjava2:rxandroid:lastest-version'
implementation 'io.reactivex.rxjava2:rxjava:lastest-version'
}
RxJava is an active library, and you should always keep the latest version for new enhancements to take effect. Therefore, we recommend that you add RxJava to the bottom of the dependency.
1.1.0 has MASSIVE breaking changes you should know about that.
The following are major changes.
First, Initialize the module using ConfigDSLBuilder
in Application
class. ConfigDSLBuilder
allows you to configure settings for each platform.
class MainApplication : Application() {
override fun onCreate() {
super.onCreate()
initSocialLogin {
facebook(getString(R.string.facebook_api_key)) {
behaviorOnCancel = true
requireWritePermissions = false
imageEnum = FacebookConfig.FacebookImageEnum.Large
}
}
}
}
Inside initSocialLogin
block, you can use methods which have platform name such as facebook and google. All parameters except setup
will necessary information to use SocialLogin feature.
setup
parameter is function that provide generate platform config object(ex, FacebookConfig) and apply additional options such as behaviorOnCancel
, imageEnum
. It can be optional, but not nullable parameters.
Although ConfigDSLBuilder
is Kotlin Type-Safe builders, but it has compatitable with Java language. we provide ConfigFunction
with same feature with original setup
higher-order function.
You can see full examples of ConfigDSLBuilder
both in Kotlin and Java
Next, Call RxSocialLogin.initialize(this)
in onCreate
methods in Activity
class before execute RxSocialLogin.result
methods.
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
...
RxSocialLogin.initialize(this)
}
From 1.1.0, RxSocialLogin
class will manage instance of Login object, so you don't need to care about initialization.
Next, Call RxSocialLogin.activityResult(requestCode, resultCode, data)
in onActivityResult
methods.
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent ? ) {
super.onActivityResult(requestCode, resultCode, data)
RxSocialLogin.activityResult(requestCode, resultCode, data)
}
Next, Call RxSocialLogin.result
where you want the results. Outside of Activity will be fine.
RxSocialLogin.result()
.subscribe({ item ->
}, { throwable ->
}).addTo(compositeDisposable)
Final, Call RxSocialLogin.login(PlatformType.FACEBOOK)
to start SocialLogin feature.
Please refer to Proguard rule of sample app.
Everything should work within the main thread. If library use a network inside the library, it will be handled correctly internally using Fuel, so the Observable
returned by RxSocialLogin
should keep the main thread. If it is not the main thread, login fails immediately.
In other words, the following cases are not processed and are treated as LoginFailedException
immediately.
RxSocialLogin.result()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
...
Due to this constraints, it is not allowed to start social login right after the network processing, such as flatMap
. If you need to handle this case, it is better to call RxSocialLogin
separately in subscribe after network processing.
A common error is OnErrorNotImplementedException, which is not handled for onError
at the time of subscribe
Based on 0.5.0 UndeliverableException occurs when Exception is not passed to onError
. You can use RxJavaPlugins.setErrorHandler { e -> }
to solve the problem, but this will change the overall behavior of RxJavaPlugins.
In 1.0.0 and later, LoginFailedException
has been changed to inheritIllegalStateException
to prevent this problem. Therefore, it is not intended to occur in later versions.
See Error handling for more details.
Currently(1.1.0), we support API 16 as minSdkVersion, but com.microsoft.identify.client:msal
library support API 21 as minSdkVersion.
According issue #263 of AzureAD/microsoft-authentication-library-for-android, You can override this library to avoid conflicts of minSdkVersion.
Place this statement in AndroidManifest.xml to solve this conflicts. we hope microsoft solve this problem asap.
<uses-sdk tools:overrideLibrary="com.microsoft.identity.msal"/>
Issue Tracker receives a variety of issues including bug findings, improvements, and new platform additions. Pull Requests is always welcome.
Copyright 2017 - 2018 WindSekirun (DongGil, Seo)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.