当前位置: 首页 > 软件库 > 手机/移动开发 > >

github-oauth

授权协议 Apache-2.0 License
开发语言 Java
所属分类 手机/移动开发
软件类型 开源软件
地区 不详
投 递 者 慕逸仙
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

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


darvid7jdamacena

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

twitter - linkedIn - blog

 相关资料
  • 所以现在我们已经介绍了 GitHub 的大部分功能与工作流程,但是任意一个小组或项目都会去自定义,因为他们想要创造或扩展想要整合的服务。 对我们来说很幸运的是,GitHub 在许多方面都真的很方便 Hack。 在本节中我们将会介绍如何使用 GitHub 钩子系统与 API 接口,使 GitHub 按照我们的设想来工作。 钩子 GitHub 仓库管理中的钩子与服务区块是 GitHub 与外部系统交互

  • 你可以在 Github 上为项目创建远程仓库。创建公开的远程仓库是免费的,私有仓库要收费。 任务 在 Github 网站申请一个帐号。 https://github.com 配置帐号的 ssh-key。 https://github.com/settings/keys ssh-key 在 Github 个人帐户里配置使用了 ssh-key,以后你往你的 Github 远程仓库推送的时候就不需要输入

  • 代码仓库 我们在GitHub上进行Tengine项目的开发:https://github.com/alibaba/tengine。 可以用git检出最新的Tengine代码: 参与开发 我们非常欢迎也很鼓励您在Tengine的项目的GitHub上报告issue或者pull request。 如果您还不熟悉GitHub的Fork and Pull开发模式,您可以阅读GitHub的文档(https:/

  • 类属性 $allowSignup 是否在登录页显示注册,默认false

  •   推荐大家使用 https://gitee.com 速度更快,项目直接部署、Android 自动构建! 私有库永久免费,提供手机客户端,国内首个同时支持 Git 和 SVN 的代码托管平台) 如何一键导入 Github 仓库:https://blog.gitee.com/2018/06/05/github_to_gitee/ GitHub 可以托管各种 git 库,并提供一个 Web 界面,但与

  • 在本章中,我们将向您展示如何使用GitHub API对用户进行身份验证。 步骤1 - 启用GitHub身份验证 打开Firebase仪表板,然后单击侧面菜单中的Auth ,然后单击标签栏中的SIGN-IN-METHOD 。 您需要启用GitHub身份验证并复制Callback URL 。 您将在步骤2中使用此选项。您可以打开此选项卡,因为完成第2步后需要添加Client ID和Client Sec