Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.idea stripped version Mar 17, 2016
gradle/wrapper stripped version Mar 17, 2016
OAuth2Client.iml stripped version Mar 17, 2016
build.gradle stripped version Mar 17, 2016
gradlew stripped version Mar 17, 2016
gradlew.bat stripped version Mar 17, 2016
oauth2-client.iml stripped version Mar 17, 2016

Custom OAuth2 Android Client

The library was developed to fit specific needs of a client, which is to complete the OAuth Authorization Code Flow using Github as the OAuth2 Provider.

Using the library

Get an instance of a provider's client:

OAuth2Client oauthClient = OAuth2ClientFactory.newInstance(OAuth2ClientFactory.Provider.ENVATO);

Build the dialog fragment to show the login/authorization screen:

OAuth2LoginFragment oAuth2LoginFragment = OAuth2LoginFragment.newInstance(oauthClient);

Set a listener responsible for intercepting the access token when appropriate:

oAuth2LoginFragment.setOnAccessTokenRequestedListener(new AccessTokenRequested() {
    public void onAccessTokenRequested(Token token) {
		Log.v("Provider", token.getProvider());
        Log.v("AccessToken", token.getAccessToken());        

Be sure to make the fragment visible whenever you want (e.g. on clicking a button):

FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.addToBackStack(null);, "oauth2_dialog");

OAuth2 Clients

Implement the base class com.gbazilio.oauth2client.oauth2.clients.interfaces.OAuth2Client if more clients are needed.