OauthLibGithub


Source link: https://github.com/geniushkg/github-oauth/

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

<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.
  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 jdamacena

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

twitter - linkedIn - blog

Resources

Record full-resolution video on your Android devices.

Available on Google Play.

BusWear is a simple library for EventBus to support Android Wear devices. Just adding one line of code lets you get synchronized event buses on Wear and mobile platform.

Qachee is a generic cache system to use specially for Android Apps. It is just a LRU Memory cache with policy expiration and lots of useful methods.

RefreshMenuItem is a Menu item that shows an indeterminate progress in the Android ActionBar. It is simple to use, lightweight, scalable and uses intuitive methods names.

What is Android Promise

A library for modular asynchronous calls.

Boogaloo is a task-retry manager with a certain back-off time.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes