forked from github/developer.github.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
299 lines (268 loc) · 13.7 KB
/
Copy pathindex.html
File metadata and controls
299 lines (268 loc) · 13.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Language" content="en-us" />
<meta http-equiv="imagetoolbar" content="false" />
<meta name="MSSmartTagsPreventParsing" content="true" />
<title>Other Authentication Methods | GitHub API</title>
<link rel="alternate" type="application/atom+xml" title="API Changes" href="/changes.atom" />
<link href="/css/reset.css" rel="stylesheet" type="text/css" />
<link href="/css/960.css" rel="stylesheet" type="text/css" />
<link href="/css/uv_active4d.css" rel="stylesheet" type="text/css" />
<link href="/shared/css/documentation.css" media="screen" rel="stylesheet" type="text/css">
<link href="/shared/css/pygments.css" media="screen" rel="stylesheet" type="text/css">
<script src="/shared/js/jquery.js" type="text/javascript"></script>
<script src="/shared/js/documentation.js" type="text/javascript"></script>
</head>
<body class="api">
<div id="header-wrapper">
<div id="header">
<div>
<a class="logo" href="/">GitHub:Developer</a>
<ul class="nav">
<li><a href="/" class="nav-overview">Overview</a></li>
<li><a href="/v3/" class="nav-api">API</a></li>
<li><a href="/changes/" class="nav-blog">Blog</a></li>
<li><a href="https://github.com/contact">Support</a></li>
<li id="search-container">
<input type="text" id="searchfield" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" /><label class="search-placeholder">Search</label>
<div class="cancel-search"></div>
<ul id="search-results">
</ul>
</li>
</ul>
</div>
</div><!-- #header -->
</div><!-- #header-wrapper -->
<div class="sub-nav">
<h2><a href="/v3/">API</a></h2>
<ul>
<li><a href="/v3/" class="active">Documentation</a></li>
<li><a href="/guides/">Guides</a></li>
<li><a href="/libraries/">Libraries</a></li>
</ul>
</div>
<div id="wrapper">
<div class="content">
<h1 id="other-authentication-methods">Other Authentication Methods</h1>
<ul id="markdown-toc">
<li><a href="#basic-authentication">Basic Authentication</a></li>
<li><a href="#working-with-two-factor-authentication">Working with two-factor authentication</a></li>
</ul>
<p>While the API provides multiple methods for authentication, we strongly
recommend using <a href="/v3/oauth/">OAuth</a> for production applications. The other
methods provided are intended to be used for scripts or testing (i.e., cases
where full OAuth would be overkill). Third party applications that rely on
GitHub for authentication should not ask for or collect GitHub credentials.
Instead, they should use the <a href="/v3/oauth">OAuth web flow</a>.</p>
<h2 id="basic-authentication">Basic Authentication</h2>
<p>The API supports Basic Authentication as defined in
<a href="http://www.ietf.org/rfc/rfc2617.txt">RFC2617</a> with a few slight differences.
The main difference is that the RFC requires unauthenticated requests to be
answered with <code>401 Unauthorized</code> responses. In many places, this would disclose
the existence of user data. Instead, the GitHub API responds with <code>404 Not Found</code>.
This may cause problems for HTTP libraries that assume a <code>401 Unauthorized</code>
response. The solution is to manually craft the <code>Authorization</code> header.</p>
<h3 id="via-username-and-password">Via Username and Password</h3>
<p>To use Basic Authentication with the GitHub API, simply send the username and
password associated with the account.</p>
<p>For example, if you’re accessing the API via <a href="http://curl.haxx.se/">cURL</a>, the following command
would authenticate you if you replace <code><username></code> with your GitHub username.
(cURL will prompt you to enter the password.)</p>
<pre class="terminal">
$ curl -u <username> https://api.github.com/user
</pre>
<h3 id="via-oauth-tokens">Via OAuth Tokens</h3>
<p>Alternatively, you can authenticate using <a href="https://github.com/blog/1509-personal-api-tokens">personal access
tokens</a> or OAuth tokens. To do so, provide the token as
the username and provide a blank password or a password of <code>x-oauth-basic</code>. If
you’re accessing the API via cURL, replace <code><token></code> with your OAuth token in
the following command:</p>
<pre class="terminal">
$ curl -u <token>:x-oauth-basic https://api.github.com/user
</pre>
<p>This approach is useful if your tools only support Basic Authentication but you
want to take advantage of OAuth access token security features.</p>
<h2 id="working-with-two-factor-authentication">Working with two-factor authentication</h2>
<p>For users with two-factor authentication enabled, Basic Authentication requires
an extra step. When you attempt to authenticate with Basic Authentication, the
server will respond with a <code>401</code> and an <code>X-GitHub-OTP: required;:2fa-type</code>
header. This indicates that a two-factor authentication code is needed (in
addition to the username and password). The <code>:2fa-type</code> in this header indicates
whether the account receives its two-factor authentication codes via SMS or via
an application.</p>
<p>In addition to the Basic Authentication credentials, you must send the user’s
authentication code (i.e., one-time password) in the <code>X-GitHub-OTP</code> header.
Because these authentication codes expire quickly, we recommend using the
Authorizations API to <a href="/v3/oauth/#create-a-new-authorization">create an access token</a> and using that
token to <a href="/v3/#authentication">authenticate via OAuth</a> for most API access.</p>
<p>Alternately, you can create access tokens from the Personal Access Token
section of your <a href="https://github.com/settings/applications">application settings page</a>.</p>
</div>
<div id="js-sidebar" class="sidebar-shell">
<div class="js-toggle-list sidebar-module expandable">
<ul>
<li class="js-topic">
<h3><a href="#" class="js-expand-btn collapsed arrow-btn"></a><a href="/v3/">Overview</a></h3>
<ul class="js-guides">
<li><a href="/v3/media/">Media Types</a></li>
<li><a href="/v3/oauth/">OAuth</a></li>
<li><a href="/v3/auth/">Other Authentication Methods</a></li>
<li><a href="/v3/troubleshooting/">Troubleshooting</a></li>
<li><a href="/v3/versions/">Versions</a></li>
</ul>
</li>
<li class="js-topic">
<h3><a href="#" class="js-expand-btn collapsed arrow-btn"></a><a href="/v3/activity/">Activity</a></h3>
<ul class="js-guides">
<li><a href="/v3/activity/events/">Events</a></li>
<li><a href="/v3/activity/events/types/">Event Types</a></li>
<li><a href="/v3/activity/feeds/">Feeds</a></li>
<li><a href="/v3/activity/notifications/">Notifications</a></li>
<li><a href="/v3/activity/starring/">Starring</a></li>
<li><a href="/v3/activity/watching/">Watching</a></li>
</ul>
</li>
<li class="js-topic">
<h3><a href="#" class="js-expand-btn collapsed arrow-btn"></a><a href="/v3/gists/">Gists</a></h3>
<ul class="js-guides">
<li><a href="/v3/gists/comments/">Comments</a></li>
</ul>
</li>
<li class="js-topic">
<h3><a href="#" class="js-expand-btn collapsed arrow-btn"></a><a href="/v3/git/">Git Data</a></h3>
<ul class="js-guides">
<li><a href="/v3/git/blobs/">Blobs</a></li>
<li><a href="/v3/git/commits/">Commits</a></li>
<li><a href="/v3/git/refs/">References</a></li>
<li><a href="/v3/git/tags/">Tags</a></li>
<li><a href="/v3/git/trees/">Trees</a></li>
</ul>
</li>
<li class="js-topic">
<h3><a href="#" class="js-expand-btn collapsed arrow-btn"></a><a href="/v3/issues/">Issues</a></h3>
<ul class="js-guides">
<li><a href="/v3/issues/assignees/">Assignees</a></li>
<li><a href="/v3/issues/comments/">Comments</a></li>
<li><a href="/v3/issues/events/">Events</a></li>
<li><a href="/v3/issues/labels/">Labels</a></li>
<li><a href="/v3/issues/milestones/">Milestones</a></li>
</ul>
</li>
<li class="js-topic">
<h3><a href="#" class="js-expand-btn collapsed arrow-btn"></a><a href="/v3/misc/">Miscellaneous</a></h3>
<ul class="js-guides">
<li><a href="/v3/emojis/">Emojis</a></li>
<li><a href="/v3/gitignore/">Gitignore</a></li>
<li><a href="/v3/markdown/">Markdown</a></li>
<li><a href="/v3/meta/">Meta</a></li>
<li><a href="/v3/rate_limit/">Rate Limit</a></li>
</ul>
</li>
<li class="js-topic">
<h3><a href="#" class="js-expand-btn collapsed arrow-btn"></a><a href="/v3/orgs/">Organizations</a></h3>
<ul class="js-guides">
<li><a href="/v3/orgs/members/">Members</a></li>
<li><a href="/v3/orgs/teams/">Teams</a></li>
</ul>
</li>
<li class="js-topic">
<h3><a href="#" class="js-expand-btn collapsed arrow-btn"></a><a href="/v3/pulls/">Pull Requests</a></h3>
<ul class="js-guides">
<li><a href="/v3/pulls/comments/">Review Comments</a></li>
</ul>
</li>
<li class="js-topic">
<h3><a href="#" class="js-expand-btn collapsed arrow-btn"></a><a href="/v3/repos/">Repositories</a></h3>
<ul class="js-guides">
<li><a href="/v3/repos/collaborators/">Collaborators</a></li>
<li><a href="/v3/repos/comments/">Comments</a></li>
<li><a href="/v3/repos/commits/">Commits</a></li>
<li><a href="/v3/repos/contents/">Contents</a></li>
<li><a href="/v3/repos/keys/">Deploy Keys</a></li>
<li><a href="/v3/repos/deployments/">Deployments</a></li>
<li><a href="/v3/repos/downloads/">Downloads</a></li>
<li><a href="/v3/repos/forks/">Forks</a></li>
<li><a href="/v3/repos/hooks/">Hooks</a></li>
<li><a href="/v3/repos/merging/">Merging</a></li>
<li><a href="/v3/repos/releases/">Releases</a></li>
<li><a href="/v3/repos/statistics/">Statistics</a></li>
<li><a href="/v3/repos/statuses/">Statuses</a></li>
</ul>
</li>
<li class="js-topic">
<h3><a href="#" class="js-expand-btn collapsed arrow-btn"></a><a href="/v3/search/">Search</a></h3>
<ul class="js-guides">
<li><a href="/v3/search/#search-repositories">Repositories</a></li>
<li><a href="/v3/search/#search-code">Code</a></li>
<li><a href="/v3/search/#search-issues">Issues</a></li>
<li><a href="/v3/search/#search-users">Users</a></li>
<li><a href="/v3/search/legacy/">Legacy Search</a></li>
</ul>
</li>
<li class="js-topic">
<h3><a href="#" class="js-expand-btn collapsed arrow-btn"></a><a href="/v3/users/">Users</a></h3>
<ul class="js-guides">
<li><a href="/v3/users/emails/">Emails</a></li>
<li><a href="/v3/users/followers/">Followers</a></li>
<li><a href="/v3/users/keys/">Public Keys</a></li>
</ul>
</li>
</ul>
</div> <!-- /sidebar-module -->
<div class="sidebar-module notice">
<p>This website is a <a href="https://github.com/github/developer.github.com" target="_blank">public GitHub repository</a>. Please help us by forking the project and adding to it.</p>
</div>
<div class="sidebar-module api-status"><a href="https://status.github.com" class="unknown">API Status</a></div>
</div><!-- /sidebar-shell -->
</div><!-- #wrapper -->
<div id="footer" >
<div class="lower_footer">
<ul class="footer-cell">
<li><a href="http://help.github.com/terms-of-service/">Terms</a></li>
<li><a href="http://help.github.com/privacy-policy/">Privacy</a></li>
<li><a href="http://help.github.com/security/">Security</a></li>
<li><a href="https://github.com/contact">Contact</a></li>
</ul>
<span class="footer-cell">
<a href="https://github.com" class="mega-octicon octicon-mark-github"></a>
</span>
<ul class="footer-cell">
<li><a href="https://status.github.com/">Status</a></li>
<li><a href="http://training.github.com/">Training</a></li>
<li><a href="http://shop.github.com/">Shop</a></li>
<li><a href="https://github.com/blog">Blog</a></li>
<li><a href="https://github.com/about">About</a></li>
</ul>
</div>
<div class="wrapper">
<p>Design © <span class="js-year">2014</span> GitHub, Inc. All rights reserved. Except where otherwise noted, content on this site is licensed under a <a href="http://creativecommons.org/licenses/by/3.0/us/">Creative Commons CC-BY license</a>.</p>
</div>
</div><!-- /#footer -->
<script type="text/javascript">
var _gauges = _gauges || [];
(function() {
var t = document.createElement('script');
t.type = 'text/javascript';
t.async = true;
t.id = 'gauges-tracker';
t.setAttribute('data-site-id', '4f2038e0cb25bc1b55000003');
t.src = '//secure.gaug.es/track.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(t, s);
})();
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-3769691-27']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<script src="/shared/js/retina.js" type="text/javascript"></script>
</body>
</html>