Simple OAuth

Additional

Language
Java
Version
1.2 (Jan 28, 2019)
Created
Jan 6, 2019
Updated
May 1, 2019 (Retired)
Owner
Roh JeongKeun (rohjk)
Contributor
Roh JeongKeun (rohjk)
1
Activity
Badge
Generate
Download
Source code

Simple OAuth

An Android Library used to Sign in Google, Facebook.

A library designed to use Oauth 2.0 easily

Simple OAuth Login!

Super simple, super easy to use!

Specs

Quick Setup

1. Include library

Using Gradle

Step 1. Add the JitPack repository to your build file

allprojects {
    repositories {
     ...
        maven { url 'https://jitpack.io' }
        
    }
}

Step 2. Add the dependency

dependencies {
    implementation 'com.github.rohjk:SimpleOAuth:1.2'
}

2. Usage

  • In AndroidManifest.xml :

Nothing

  • In Activity :

a. Set IDP Provider

set Google OAuth 2.0 'Web Client ID', Facebook 'App ID'

 SimpleSession.setAuthProvider(IdpType.GOOGLE,"<OAuth 2.0 Web Client ID>");
 SimpleSession.setAuthProvider(IdpType.FACEBOOK,"<App ID>");

b. Override onActivityResult

@Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        SimpleSession.onActivityResult(requestCode,resultCode,data);
    }

C. Call Login API

 IdpType idpType; // IdpType.GOOGLE or IdpType.FACEBOOK
 
 SimpleSession.login(this, idpType, new SimpleAuthResultCallback<Void>() {
          @Override
          public void onResult(SimpleAuthResult<Void> result) {
               if(result.isSuccess()){
                    //Success to Login!
                }else{
      //Fail to Login!
                    int errorCode = result.getErrorCode();
                    String errorMessage = result.getErrorMessaage();
                }
          }
 });

D. Done! Super Simple

3. Others

A. Get Sign in Status

 SimpleSession.isSignedIn(<Activity>);

B. Get Signed IDP Type

 SimpleSession.getCurrentIdpType();

C. Get Access Token

 SimpleSession.getAccessToken();

D. Get Email

 SimpleSession.getEmail();

E. Logout

 SimpleSession.logout();

3. dependencies

play-services-auth:16.0.1 , facebook-android-sdk:4.+