Coder Social home page Coder Social logo

easysocial's Introduction

EasySocial

Oauth2.0 general implementation for Android. In our mostly Android apps, we want to integrate Facebook, Google etc for sign-in or share purpose. For that we add Facebook SDK , Google play service for Google+ and we only want one functionality. Its mean we are adding a long list of methods in our app but we only want one method. Instead many developers face multidex issue due to increase in method limit. Also one more issue, first I need to learn how integrate Facebook then Google then Twitter and a long list. So I feel, I create a one generic module which we use for every Social network. So for that purpose I created a Oauth2.0 Module. So any Social Network who uses Oauth2.0 for authentication, you can use this module for that Social Network.

How to Use.

Simple add this module in your project and call the below code for authentication.

    Intent intent = new Intent(this, EasySocialAuthActivity.class);
    String loginUrl = "https://www.facebook.com/dialog/oauth?" +
            "client_id=xxxxxxxxxxxxxx&" +
            "redirect_uri=https://www.uwanttolearn.com/&" +
            "scope=email,publish_actions";
    intent.putExtra(EasySocialAuthActivity.URL, loginUrl);
    intent.putExtra(EasySocialAuthActivity.REDIRECT_URL,      "http://www.uwanttolearn.com/");
    String accessTokenUrl = "https://graph.facebook.com/oauth/access_token?" +
            "client_id=xxxxxxxxxxxxxx&" +
            "redirect_uri=https://www.uwanttolearn.com/&" +
            "client_secret=xxxxxxxxxxxx&" +
            "code=";
    intent.putExtra(EasySocialAuthActivity.ACCESS_TOKEN, accessTokenUrl);
    startActivityForResult(intent, REQUEST_CODE);

And implement the onActivityResult method to get the response of authentication.

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if(resultCode == RESULT_OK){
        if(requestCode == REQUEST_CODE){
                String accessToken = data.getStringExtra("data");
        }
    }else if(resultCode == RESULT_CANCELED){
        if(requestCode == REQUEST_CODE) {
            Toast.makeText(this, data.getIntExtra(EasySocialAuthActivity.ERROR_CODE, 0) + "", Toast.LENGTH_LONG).show();
            //These error codes are present in WebViewClient.              
            //http://developer.android.com/reference/android/webkit/WebViewClient.html
        }
    }

}

For more information you can read the tutorial where I explain this module completly. How to use this moduel in Android apps. http://www.uwanttolearn.com/android/android-oauth-2-0/

easysocial's People

Watchers

 avatar James Cloos avatar

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.