-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoken.ml
28 lines (23 loc) · 829 Bytes
/
token.ml
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
open Core.Std
let get_id = "5748885591ce2c8246852e66"
let get_secret = In_channel.read_all "../moonlandings.txt"
|> String.strip
let create_auth =
let client_id = "5748885591ce2c8246852e66" in
let auth = client_id ^ ":" ^ get_secret in
let enc = B64.encode auth in
let auth_headers = ["Authorization", "Basic " ^ enc] in
auth_headers
let generate_uri code =
let uri = Uri.of_string "https://coggle.it/token" in
Uri.add_query_params uri[
("code", [code]);
("grant_type", ["authorization_code"]);
("redirect_uri", ["http://localhost:8080/coggle"])]
let parse_token str =
let json = Yojson.Basic.from_string str in
let open Yojson.Basic.Util in
let tkn = json |> member "access_token" |> to_string in
(* print_endline ("Tkn: " ^ tkn) *)
(* printf "Tkn: %s\n" tkn *)
tkn