![](/style/images/good.png)
![](/style/images/bad.png)
Github 基本认证
source link: https://simpleowen.github.io/post/basic_authorization_github/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Github 基本认证
2019-06-19 236 words 1 min read
通过 Github API v3 进行认证的方式有 2 类
Basic authentication
- Username and Password
- Personal Access Token
OAuth2
- OAuth2 token (sent in a header)
- OAuth2 key/secret
这 3 种认证方式的认证格式如下:
curl -u "username" https://api.github.com curl -H "Authorization: token OAUTH-TOKEN" https://api.github.com curl 'https://api.github.com/users/whatever?client_id=xxxx&client_secret=yyyy'
本文只介绍 Github 的基本认证 (Basic authentication), 尽管如此, Github 官方强烈建议用户使用 OAuth 进行生产环境的认证
Github 基本认证实现了 RFC2617 标准, 只在返回未经认证的请求时略有差异. RFC2617 要求返回 401 Unauthorized, 但 Github API v3 返回 404 Not Found
可通过 2 种方式进行 GitHub 基本认证
通过 用户名 和 密码
curl -u username https://api.github.com/user
这样访问, curl 会提示输入密码
通过 OAuth 令牌 (OAuth Tokens)
curl -u username:token https://api.github.com/user
使用 personal access tokens 或 OAuth 令牌代替密码也是方案之一
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK