Skip to content

Commit d6e5d6c

Browse files
committed
Add oauth2 docs into main v3 site
1 parent 60aaa94 commit d6e5d6c

File tree

4 files changed

+144
-7
lines changed

4 files changed

+144
-7
lines changed

content/index.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ title: developer.github.com
44

55
# developer.github.com
66

7-
This describes the Resources that make up the official GitHub API v3. If
7+
This describes the resources that make up the official GitHub API v3. If
88
you have any problems or requests please contact
99
[support](mailto:support@github.com?subject=APIv3).
1010

11-
For the new API v3, start browsing the implemented resources on the
12-
right >>
11+
For the new API v3, start browsing the resources on the right >>
1312

1413
## Breaking BETA Changes
1514

content/v3.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Issues API v3 | developer.github.com
44

55
# API v3
66

7-
This describes the Resources that make up the official GitHub API v3. If
7+
This describes the resources that make up the official GitHub API v3. If
88
you have any problems or requests please contact
99
[support](mailto:support@github.com?subject=APIv3).
1010

@@ -149,7 +149,7 @@ OAuth2 Token (sent as a parameter):
149149
$ curl https://api.github.com?access_token=OAUTH-TOKEN
150150
</pre>
151151

152-
Read [more about OAuth2](http://develop.github.com).
152+
Read [more about OAuth2](/v3/oauth/).
153153

154154
## Pagination
155155

content/v3/oauth.md

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
---
2+
title: OAuth | developer.github.com
3+
---
4+
5+
# OAuth
6+
7+
OAuth2 is a protocol that lets external apps request authorization to
8+
private details in a user's GitHub account without getting their
9+
password. This is preferred over Basic Authentication because tokens can
10+
be limited to specific types of data, and can be revoked by users at any
11+
time.
12+
13+
All developers need to [register their
14+
application](https://github.com/account/applications/new) before getting
15+
started. A registered OAuth application is assigned a unique Client ID
16+
and Client Secret. The Client Secret should not be shared.
17+
18+
## Web Application Flow
19+
20+
This is a description of the OAuth flow from 3rd party web sites.
21+
22+
### 1. Redirect users to request GitHub access
23+
24+
GET https://github.com/login/oauth/authorize
25+
26+
### Parameters
27+
28+
client\_id
29+
: _Required_ **string** - The client ID you received from GitHub when
30+
you [registered](https://github.com/account/applications/new).
31+
32+
redirect\_uri
33+
: _Optional_ **string** - URL in your app where user's will be sent
34+
after authorization. See details below about [redirect
35+
urls](#redirect-urls).
36+
37+
scope
38+
: _Optional_ **string** - Comma separated list of [scopes](#scopes).
39+
40+
### 2. GitHub redirects back to your site
41+
42+
If the user accepts your request, GitHub redirects back to your site
43+
with a temporary code in a code parameter. Exchange this for an access
44+
token:
45+
46+
POST https://github.com/login/oauth/access_token
47+
48+
### Parameters
49+
50+
client\_id
51+
: _Required_ **string** - The client ID you received from GitHub when
52+
you [registered](https://github.com/account/applications/new).
53+
54+
redirect\_uri
55+
: _Optional_ **string**
56+
57+
client\_secret
58+
: _Required_ **string** - The client secret you received from GitHub
59+
when you [registered](https://github.com/account/applications/new).
60+
61+
code
62+
: _Required_ **string** - The code you received as a response to [Step 1](#redirect-users-to-request-github-access).
63+
64+
### Response
65+
66+
access\_token
67+
: _Required_ **string** - OAuth access token.
68+
69+
### 3. Use the access token to access the API
70+
71+
The access token allows you to make requests to the API on a behalf of a user.
72+
73+
GET https://api.github.com/user?access_token=...
74+
75+
## Desktop Application Flow
76+
77+
Use basic authentication for now...
78+
79+
## Redirect URLs
80+
81+
The `redirect_uri` parameter is optional. If left out, GitHub will
82+
redirect users to the callback URL configured in the OAuth Application
83+
settings. If provided, the redirect URL must match the callback URL's
84+
host.
85+
86+
CALLBACK: http://foo.com
87+
88+
GOOD: https://foo.com
89+
GOOD: http://foo.com/bar
90+
BAD: http://foo:com:8080
91+
BAD: http://bar.com
92+
93+
## Scopes
94+
95+
Scopes let you specify exactly what type of access you need. This will
96+
be displayed to the user on the authorize form.
97+
98+
(no scope)
99+
: public read-only access (includes public user profile info, public
100+
repo info, and gists).
101+
102+
user
103+
: DB read/write access to profile info only.
104+
105+
public\_repo
106+
: DB read/write access, and Git read access to public repos.
107+
108+
repo
109+
: DB read/write access, and Git read access to public and private repos.
110+
111+
gist
112+
: write access to gists.
113+
114+
NOTE: Your application can request the scopes in the initial redirection. You
115+
can specify multiple scopes by separating them by a comma.
116+
117+
https://github.com/login/oauth/authorize?
118+
client_id=...&
119+
scope=user,public_repo
120+
121+
122+
## More Information
123+
124+
It can be a little tricky to get started with OAuth. Here are a few
125+
links that might be of help:
126+
127+
* [OAuth 2 spec](http://tools.ietf.org/html/draft-ietf-oauth-v2-07)
128+
* [Facebook API](http://developers.facebook.com/docs/authentication/)
129+
* [Ruby OAuth2 lib](https://github.com/intridea/oauth2)
130+
* [simple ruby/sinatra example](https://gist.github.com/9fd1a6199da0465ec87c)
131+
* [simple python example](https://gist.github.com/e3fbd47fbb7ee3c626bb) using [python-oauth2](http://github.com/dgouldin/python-oauth2)
132+
* [Ruby OmniAuth example](http://github.com/intridea/omniauth)
133+
* [Ruby Sinatra extension](http://github.com/atmos/sinatra_auth_github)
134+
* [Ruby Warden strategy](http://github.com/atmos/warden-github)
135+
* [Node.js demo using Nozzle](http://github.com/fictorial/nozzle/blob/master/demo/08-github-oauth2.js)

layouts/default.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
<li>
4343
<h3><a href="/v3/">Summary</a></h3>
4444
<span class="spacer"></span>
45+
<ul>
46+
<li><a href="/v3/oauth/">OAuth</a></li>
47+
</ul>
4548
</li>
4649
<li>
4750
<h3><a href="/v3/gists/">Gists</a></h3>
@@ -53,10 +56,10 @@ <h3><a href="/v3/gists/">Gists</a></h3>
5356
<h3><a href="/v3/git/">Git Data</a></h3>
5457
<ul>
5558
<li><a href="/v3/git/blobs/">Blobs</a></li>
56-
<li><a href="/v3/git/trees/">Trees</a></li>
5759
<li><a href="/v3/git/commits/">Commits</a></li>
58-
<li><a href="/v3/git/tags/">Tags</a></li>
5960
<li><a href="/v3/git/refs/">References</a></li>
61+
<li><a href="/v3/git/tags/">Tags</a></li>
62+
<li><a href="/v3/git/trees/">Trees</a></li>
6063
</ul>
6164
</li>
6265
<li>

0 commit comments

Comments
 (0)