Giter Club home page Giter Club logo

rxsociallogin's Introduction

RxSocialLogin

Awesome Kotlin Badge

The license information for logo is located at the bottom of the document.

These instructions are available in their respective languages.

Introduction

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.

  • The result delivery method has been changed to be passed through RxJava instead of the Listener.
  • Compared to the original written in Java, the improved version is written in Kotlin only.
  • Compared to the original supported 6 platforms, the improved version is support 15 platforms.
  • Provide Type-Safe builder with Kotlin DSL
  • All methods and code have been rewritten.
  • All code that are written in Kotlin but considered to be Java compatible.

Supported Platforms

Platform Data Version
Disqus id, name, email, nickname, profilePicture, accessToken 1.0.0
Facebook 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
Google 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
LinkedIn 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
Twitter 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.

Import

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.

  • RxAndroid:
  • RxJava:

Migrate from 1.0.0

1.1.0 has MASSIVE breaking changes you should know about that.

The following are major changes.

  • Migrate to Java Builder to DSL Builder
  • Initialize in RxSocialLogin as once
  • Call onActivityResult as once
  • Migrate receive result with RxSocialLogin.result()

Release Notes are here

Very easy 5-step usage

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.

Instructions for use

Apply to Proguard

Please refer to Proguard rule of sample app.

Constraints - all actions should keep the main thread

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.

Occurred OnErrorNotImplementedException

A common error is OnErrorNotImplementedException, which is not handled for onError at the time of subscribe

Occurred UndeliverableException

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 inherit IllegalStateException to prevent this problem. Therefore, it is not intended to occur in later versions.

See Error handling for more details.

Targeting below of API 21

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"/>

Author & Contributor

Issue Tracker receives a variety of issues including bug findings, improvements, and new platform additions. Pull Requests is always welcome.

License

  • The ReactiveX logo was taken from Seeklogo.
  • The font used for the logo is Hanken Design Co. Hanken round and this font follows SIL OFL. There is a PSD file for the logo in the project.
  • Copyright for the platform logo used in the sample exists in each company. The RxSocialLogin library is not associated with the platform company.
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.

rxsociallogin's People

Contributors

windsekirun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rxsociallogin's Issues

Simplify RxSocialLogin.** methods into one methods

Affect Version: 1.1(Remove)
Currently there are separate methods for each platform, so there is a lot of work to be done when adding a new platform.

In addition, we already provide platform information in LoginResultItem, so we do not need any distinction in Observable.

Notification from Google Play

I received notification from Google Play:

Your application uses a WebView component that is vulnerable to cross-scripting. Detailed information can be found in this article.
Vulnerable classes:
com.kakao.auth.authorization.authcode.KakaoWebViewActivity-> initUi
Fix the problem before: 03/18/2020

gradlew client-v3:dependencies
shows that this class from RxSocialLogin library:

+--- com.github.WindSekirun:RxSocialLogin:1.2.5.3-androidx
|    ...
|    +--- com.kakao.sdk:usermgmt:1.14.0
|    |    \--- com.kakao.sdk:auth:1.14.0
|    |         +--- com.kakao.sdk:network:1.14.0
|    |         |    \--- com.kakao.sdk:util:1.14.0
|    |         \--- androidx.fragment:fragment:1.0.0 -> 1.1.0 (*)
|    ...

Twitter Profile Image

Please include this functionality, that we can get the profile image url of the twitter account.

Duplicate class com.android.vending.billing.IInAppBillingService found in modules ?

안녕하세요. 노고가 많으십니다.
Duplicate class com.android.vending.billing.IInAppBillingService found in modules jetified-RichUtilsKt-2.3.1-runtime.jar (com.github.WindSekirun:RichUtilsKt:2.3.1) and jetified-library-1.0.44.jar (com.anjlab.android.iab.v3:library:1.0.44)
이거 어떻게 해결하는지 몰겠는데... 좀 도와주시면 안되나요?
com.anjlab.android.iab.v3:library:1.0.44 이걸로 인앱결제 추가 해놨는데
두개 동시에 못쓰는건가요?
소셜로긴인데 왜 IInAppBillingService 부분이 문제가 될까요?
초보라 잘부탁듸립니다.

Fails to build when Proguard is enabled

Hello,

Please can you verify that your library can be built with Proguard enabled, as when i comment the library my project builds fine with proguard, but when i then include the rxsocial login it doesnt.

Regards
Sunny

google login crash onActivitiyResult

It seems the google authentication, doesnt seem to work. Please is there anything that i might be doing wrong. i have also enabled the option on firebase and produced a debugged version of the SHA1 hash key. i also downloaded the google services json in my project. Please what can i be doing wrong that it calls back with Google sign in failed

Crash when opened the app due to not updated sdks

Rejecting re-init on previously-failed class java.lang.Class<com.google.firebase.auth.FirebaseAuth>: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/internal/InternalTokenProvider;

Plan of 1.3.0

It has been a long time since I had planned.

RxSocialLogin 1.3.0 will cover these feature.

  • New Platform: Discord, Bitbucket, Gitlab, Amazon, Paypal, Facebook Account Kit, Instagram (#20, #22, #23, #24, #25, #41, #43) and more..?
  • Resolve error on GoogleLogin in Fragment (#44)
  • New sample application design (#49)
  • Use RxSocialLogin without RxJava -> In 1.5.0

Also, RxSocialLogin will remove support of the non-androidx project in 1.3.0. That means all new version above 1.3.0 will provide only androidx version.
But you can use 1.2.1 if you want to continue this library in the non-androidx project.

Any suggestions or questions are welcome.

Todos

  • Discord
  • Bitbucket
  • Gitlab
  • Amazon
  • Paypal
  • Facebook Account Kit
  • Instagram
  • Resolve #44
  • Resolve #49
  • Use RxSocialLogin without RxJava -> In 1.5.0
  • Refactor code using Codacy

Edit in 2019-02-12

  • Paypal: I can't find any information for acquiring access_token without button. So, I can't implement this feature.
  • Use RxSocialLogin without RxJava: Need some time to think about api design. this feature can occur some big changes, so leave that in now.

Crash on KakaoLogin - profilePicture must not be null

Fatal Exception: java.lang.IllegalStateException: profilePicture must not be null
       at com.github.windsekirun.rxsociallogin.kakao.KakaoLogin$requestMe$1.onSuccess(KakaoLogin.kt:124)
       at com.github.windsekirun.rxsociallogin.kakao.KakaoLogin$requestMe$1.onSuccess(KakaoLogin.kt:84)
       at com.kakao.network.callback.ResponseCallback.onSuccessForUiThread(ResponseCallback.java:76)
       at com.kakao.network.tasks.KakaoResultTask$1$1.run(KakaoResultTask.java:78)
       at android.os.Handler.handleCallback(Handler.java:789)
       at android.os.Handler.dispatchMessage(Handler.java:98)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6944)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

Not getting result after login

For facebook login not getting result
RxSocialLogin.result(this).subscribe({
Timber.d { "FirstName: ${it.firstName}" }
},
{ Timber.e(it.cause)})
After onActivityResult.

A small concern - initialization of necessary objects at once ..?

Affect Version: ??

At this time, user(developer) will initialize 'Social module object' in Activity as count of the platform to use.
But we think there are some tiresome of initialize all of module object in one code.

'Initialize in RxSocialLogin' is solution to solve this 'tiresome', but there are so many changes of achieve this solution.

First, we need to remove verbose of RxSocialLogin object by remove their roles.

There some roles which RxSocialLogin have.

  1. Abstract class of ‘Social module object’
  2. Provide helper methods
  3. Manage Config object of ‘Social module object’

So, we can remove first roles by divide to BaseSocialLogin object and make ‘RxSocialLogin` is kotlin object class. Other roles are proper roles of new ‘RxSocialLogin’ object, so we can retain them.

Most important thing of this changes is reducing ‘breaking changes’ while version migration. So, we have to change internal logic, not outside logic.

Migrate with RxActivityResult

Since some SDKs handle them internally, this feature is not 100% supported. But if platform support it, it will implement the feature as much as possible.

Check 'NotSupportError' on KakaoLogin

Error log: Bundle[{com.kakao.sdk.talk.error.type=NotSupportError, com.kakao.sdk.talk.error.description=KakaoTalk is installed but not connected to Kakao account.}]

We can find this logs from KakaoLogin.onActivityResult. this exception will be passed into onSessionClosed methods, but the message is 'authentication failed'

Situation: The user installed KakaoTalk application in the device, but not connected any account of Kakao

implement RxSocialLogin.setPlatformConfig

It will available to change the parameter of config in Runtime.
but, it will not allow adding a new config for platforms not created through the Application class.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.