Skip to content

Commit 62c1c86

Browse files
committed
user: Extend github_authorize() documentation
1 parent 5ffb3bc commit 62c1c86

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/user/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,20 @@ impl Model for User {
137137
}
138138

139139
/// Handles the `GET /authorize_url` route.
140+
///
141+
/// This route will return an authorization URL for the GitHub OAuth flow including the crates.io
142+
/// `client_id` and a randomly generated `state` secret.
143+
///
144+
/// see https://developer.github.com/v3/oauth/#redirect-users-to-request-github-access
145+
///
146+
/// ## Response Body Example
147+
///
148+
/// ```json
149+
/// {
150+
/// "state": "b84a63c4ea3fcb4ac84",
151+
/// "url": "https://github.com/login/oauth/authorize?client_id=...&state=...&scope=read%3Aorg"
152+
/// }
153+
/// ```
140154
pub fn github_authorize(req: &mut Request) -> CargoResult<Response> {
141155
// Generate a random 16 char ASCII string
142156
let state: String = thread_rng().gen_ascii_chars().take(16).collect();

0 commit comments

Comments
 (0)