Skip to content

kakadu-dev/android-sociallogin

Repository files navigation

android-sociallogin

Release GitHub license

Easy login with Google, Facebook, VK for android apps

Use:

    fun loginWithGoogle() {
        startActivityForResult(SocialLogin.loginIntent(this, LoginType.GOOGLE), 0)
    }

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        val loginResult: LoginResult? = data?.loginResult
        // do something
    }

Get user info:

    val withInfo = SocialLogin.getResultWithUserInfo(loginResult)
    val avatar = withInfo.avatar
    val email = withInfo.email
    val firstName = withInfo.firstName
    val lastName = withInfo.lastName

Request other permissions:

    // for VK
    SocialLogin.loginIntent(this, LoginType.VK, VKScope.FRIENDS.name, VKScope.PHONE.name)
    
    // for Facebook
    SocialLogin.loginIntent(this, LoginType.FB, "user_friends")

Setup

First you need to register your app:

Then add the received resources to your app:

<resources>

  <!--For Google (optional)-->
  <string name="default_web_client_id">...</string>

  <!--For Facebook (required)-->
  <string name="facebook_app_id">...</string>
  <string name="fb_login_protocol_scheme">...</string>

  <!--For VK (required)-->
  <integer name="com_vk_sdk_AppId">...</integer>

</resources>

Add the dependency in your build.gradle file:

repositories {  
    maven { url "https://jitpack.io" }  
}  
  
dependencies { 
	// For all social networks 
	implementation 'com.github.kakadu-dev:android-sociallogin:1.2.13'
    // also for Huawei
    implementation 'com.huawei.hms:hwid:6.4.0.300'
	
	// or exclude some
    implementation('com.github.kakadu-dev:android-sociallogin:1.2.13') {
        exclude group: 'com.vk' //without VK  
        exclude group: 'com.facebook.android' //without Facebook  
        exclude group: 'com.google.android.gms' //without Google  
    }  
}  

About

Easy login with Google, Facebook, VK for android apps

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages