Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Android library to add oauth login flow for github , minimum api 14

License

NotificationsYou must be signed in to change notification settings

geniushkg/github-oauth

Repository files navigation

Simple library to integrate Github authentication to android app using OAuth.

Installation

compile 'com.github.geniushkg:oauthLibGithub:1.0.2'

Add to manifest

<uses-permission android:name="android.permission.INTERNET"/>

and activity declaration:

<activity android:name="com.hardikgoswami.oauthLibGithub.OauthActivity"/>

Github Auth Flow

Initialise new Auth instance with credentials

  1. Client id : you get it from your github profile by creating new app.
    Follow this tutorial
  2. Client Secret : same as above.
  3. NextActivity : Thats your activity you want launch after user gets authenticated.
  4. Context : you can use context variable from place where initiate the process that is getActivity() from fragment or getapplicationcontext() from activity.

Sample initialization :

    // Github ID and secret are generated in github.com profile// package name is your packagename// next activity is your activity with full name including package // you can use debug(true) for logcat , use TAG = "github-oauth"// scope can also be defined (optional)loginButton.setOnClickListener(new View.OnClickListener() {        @Override        public void onClick(View v) {             GithubOauth                    .Builder()                    .withClientId(GITHUB_ID)                    .withClientSecret(GITHUB_SECRET)                    .withContext(context)                    .packageName("com.hardikgoswami.github_oauth_lib")                    .nextActivity("com.hardikgoswami.github_oauth_lib.UserActivity")                    .debug(true)                     .execute();        }    });

Note : Callback url can be as per your requirement or make ithttp://localhost while registering new Oauth application.

Note 2: Available scopes are presented on the table below

ScopeDescription
repo:statusAccess commit status
repo_deploymentAccess deployment status
public_repoAccess public repositories
admin:orgFull control of orgs and teams
write:orgRead and write org and team membership
read:orgRead org and team membership
admin:public_keyFull control of user public keys
write:public_keyWrite user public keys
read:public_keyRead user public keys
admin:repo_hookFull control of repository hooks
write:repo_hookWrite repository hooks
read:repo_hookRead repository hooks
admin:org_hookFull control of organization hooks
gistCreate gists
notificationsAccess notifications
userUpdate all user data
read:userRead all user profile data
user:emailAccess user email addresses (read-only)
user:followFollow and unfollow users
delete_repoDelete repositories
admin:gpg_keyFull control of user gpg keys (Developer Preview)
write:gpg_keyWrite user gpg keys
read:gpg_keyRead user gpg keys

Execute will launch a new activity with webview and user token will be stored in shared preference

shared preference name : github_prefs

String in preference : oauth_token

// Sample to read logged in user oauth token    public static final String PREFERENCE = "github_prefs";sharedPreferences = getSharedPreferences(PREFERENCE, 0);    String oauthToken = sharedPreferences.getString("oauth_token", null);    Log.d(TAG, "oauth token for github loged in user is :" + oauthToken);

if you found any bug you can create issue or want to contribute feel free to PR.

Contributor's


darvid7jdamacena

For new programmer's -> do not hesitate, please send PR we both will learn something new. :)

twitter -linkedIn -blog

About

Android library to add oauth login flow for github , minimum api 14

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors3

  •  
  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp