https://github.com/geniushkg/github-oauth
Android library to add oauth login flow for github , minimum api 14
https://github.com/geniushkg/github-oauth
android authentication-flow github-api github-oauth oauth sdk-android
Last synced: 3 days ago
JSON representation
Android library to add oauth login flow for github , minimum api 14
- Host: GitHub
- URL: https://github.com/geniushkg/github-oauth
- Owner: geniushkg
- License: other
- Created: 2016-11-02T06:23:30.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2020-02-04T07:26:14.000Z (almost 6 years ago)
- Last Synced: 2024-02-06T17:29:24.709Z (almost 2 years ago)
- Topics: android, authentication-flow, github-api, github-oauth, oauth, sdk-android
- Language: Java
- Size: 514 KB
- Stars: 53
- Watchers: 2
- Forks: 19
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: License
Awesome Lists containing this project
README
# github-oauth
Simple library to integrate Github authentication to android app using OAuth.
## Installation
compile 'com.github.geniushkg:oauthLibGithub:1.0.2'
Add to manifest
and activity declaration:
## 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](https://developer.github.com/apps/building-oauth-apps/creating-an-oauth-app/)
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 it http://localhost while registering new Oauth application.
**Note 2:** Available scopes are presented on the table below
Scope | Description
----------------------|---------------------
repo:status | Access commit status
repo_deployment | Access deployment status
public_repo | Access public repositories
admin:org | Full control of orgs and teams
write:org | Read and write org and team membership
read:org | Read org and team membership
admin:public_key | Full control of user public keys
write:public_key | Write user public keys
read:public_key | Read user public keys
admin:repo_hook | Full control of repository hooks
write:repo_hook | Write repository hooks
read:repo_hook | Read repository hooks
admin:org_hook | Full control of organization hooks
gist | Create gists
notifications | Access notifications
user | Update all user data
read:user | Read all user profile data
user:email | Access user email addresses (read-only)
user:follow | Follow and unfollow users
delete_repo | Delete repositories
admin:gpg_key | Full control of user gpg keys (Developer Preview)
write:gpg_key | Write user gpg keys
read:gpg_key | Read 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
_________________________________________________
[darvid7](https://github.com/darvid7 "Darvid7")
[jdamacena](https://github.com/jdamacena "jdamacena")
For new programmer's -> do not hesitate, please send PR we both will learn something new. :)
[twitter](https://twitter.com/geniushkg "Goswami Hardik") - [linkedIn](https://www.linkedin.com/in/geniushkg "Goswami Hardik") - [blog](http://hardikgoswami.com "Goswami Hardik")