-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an option to start a local web server for OAuth2 flow. - oauth2_loopback: flag to start the local web server - oauth2_loopback_port: port of the local web server [defaults to 8080]
- Loading branch information
Showing
32 changed files
with
281 additions
and
373 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
version=0.19.0 | ||
version=0.20.1 | ||
profile=conventional |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
open GapiLens.Infix | ||
module S = Tiny_httpd | ||
|
||
let build_page title h3 body = | ||
Printf.sprintf | ||
"<!DOCTYPE html>\n\ | ||
<html lang=\"en\">\n\ | ||
<head>\n\ | ||
<title>%s</title>\n\ | ||
</head>\n\ | ||
<body>\n\ | ||
<h3>%s</h3>\n\ | ||
%s\n\ | ||
</body>\n\ | ||
</html>" | ||
title h3 body | ||
|
||
let start port = | ||
let server = S.create ~port () in | ||
S.add_route_handler server | ||
S.Route.(exact "oauth2callback" @/ return) | ||
(fun req -> | ||
let query = S.Request.query req in | ||
let response = | ||
try | ||
let verification_code = | ||
List.find (fun (key, _) -> key = "code") query |> snd | ||
in | ||
Context.update_ctx (Context.verification_code ^= verification_code); | ||
S.Response.make_string | ||
(Ok | ||
(build_page "gdfuse oauth2 flow" "Success!" | ||
(Printf.sprintf | ||
"<p>Verification code: %s</p><p>You may close the \ | ||
browser. Please, check the console output of the \ | ||
application.</p>" | ||
verification_code))) | ||
with Not_found -> | ||
S.Response.make_string | ||
(Ok | ||
(build_page "gdfuse oauth2 flow" "Error!" | ||
(Printf.sprintf "<p>Cannot get the verification code</p>"))) | ||
in | ||
S.stop server; | ||
response); | ||
Utils.log_with_header | ||
"Starting OAuth2 local web server. Listening on http://%s:%d\n%!" | ||
(S.addr server) (S.port server); | ||
Thread.create | ||
(fun () -> match S.run server with Ok () -> () | Error e -> raise e) | ||
() | ||
|> ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
val start : int -> unit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
val start_folder_fetching_thread : CacheData.t -> (string -> unit) -> unit | ||
|
||
val stop_folder_fetching_thread : unit -> unit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.