Skip to content

Commit 5ffb3bc

Browse files
committed
user: Extend github_access_token() documentation
1 parent df633f9 commit 5ffb3bc

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/user/mod.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,33 @@ pub fn github_authorize(req: &mut Request) -> CargoResult<Response> {
150150
}
151151

152152
/// Handles the `GET /authorize` route.
153+
///
154+
/// This route is called from the GitHub API OAuth flow after the user accepted or rejected
155+
/// the data access permissions. It will check the `state` parameter and then call the GitHub API
156+
/// to exchange the temporary `code` for an API token. The API token is returned together with
157+
/// the corresponding user information.
158+
///
159+
/// see https://developer.github.com/v3/oauth/#github-redirects-back-to-your-site
160+
///
161+
/// ## Query Parameters
162+
///
163+
/// - `code` – temporary code received from the GitHub API **(Required)**
164+
/// - `state` – state parameter received from the GitHub API **(Required)**
165+
///
166+
/// ## Response Body Example
167+
///
168+
/// ```json
169+
/// {
170+
/// "api_token": "b84a63c4ea3fcb4ac84",
171+
/// "user": {
172+
/// "email": "[email protected]",
173+
/// "name": "Foo Bar",
174+
/// "login": "foobar",
175+
/// "avatar": "https://avatars.githubusercontent.com/u/1234",
176+
/// "url": null
177+
/// }
178+
/// }
179+
/// ```
153180
pub fn github_access_token(req: &mut Request) -> CargoResult<Response> {
154181
// Parse the url query
155182
let mut query = req.query();

0 commit comments

Comments
 (0)