Source file gapiAuthResponse.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
module Option = GapiOption

module ClientLogin = struct
  type auth_token = string
  type captcha = { url : string; token : string }

  let url =
    {
      GapiLens.get = (fun x -> x.url);
      GapiLens.set = (fun v x -> { x with url = v });
    }

  let token =
    {
      GapiLens.get = (fun x -> x.token);
      GapiLens.set = (fun v x -> { x with token = v });
    }
end

module OAuth1 = struct
  type request_token = {
    request_token : string;
    request_token_secret : string;
    callback_confirmed : bool;
  }

  let request_token =
    {
      GapiLens.get = (fun x -> x.request_token);
      GapiLens.set = (fun v x -> { x with request_token = v });
    }

  let request_token_secret =
    {
      GapiLens.get = (fun x -> x.request_token_secret);
      GapiLens.set = (fun v x -> { x with request_token_secret = v });
    }

  let callback_confirmed =
    {
      GapiLens.get = (fun x -> x.callback_confirmed);
      GapiLens.set = (fun v x -> { x with callback_confirmed = v });
    }

  type auth_token = { auth_token : string; verifier : string }

  let auth_token =
    {
      GapiLens.get = (fun x -> x.auth_token);
      GapiLens.set = (fun v x -> { x with auth_token = v });
    }

  let verifier =
    {
      GapiLens.get = (fun x -> x.verifier);
      GapiLens.set = (fun v x -> { x with verifier = v });
    }

  type access_token = { access_token : string; access_token_secret : string }

  let access_token =
    {
      GapiLens.get = (fun x -> x.access_token);
      GapiLens.set = (fun v x -> { x with access_token = v });
    }

  let access_token_secret =
    {
      GapiLens.get = (fun x -> x.access_token_secret);
      GapiLens.set = (fun v x -> { x with access_token_secret = v });
    }
end

module AuthSub = struct
  type token_info = { target : string; scope : string; secure : bool }

  let target =
    {
      GapiLens.get = (fun x -> x.target);
      GapiLens.set = (fun v x -> { x with target = v });
    }

  let scope =
    {
      GapiLens.get = (fun x -> x.scope);
      GapiLens.set = (fun v x -> { x with scope = v });
    }

  let secure =
    {
      GapiLens.get = (fun x -> x.secure);
      GapiLens.set = (fun v x -> { x with secure = v });
    }
end

module OAuth2 = struct
  type auth_code = string

  type access_token = {
    access_token : string;
    token_type : string;
    expires_in : int;
    refresh_token : string;
  }

  let access_token =
    {
      GapiLens.get = (fun x -> x.access_token);
      GapiLens.set = (fun v x -> { x with access_token = v });
    }

  let token_type =
    {
      GapiLens.get = (fun x -> x.token_type);
      GapiLens.set = (fun v x -> { x with token_type = v });
    }

  let expires_in =
    {
      GapiLens.get = (fun x -> x.expires_in);
      GapiLens.set = (fun v x -> { x with expires_in = v });
    }

  let refresh_token =
    {
      GapiLens.get = (fun x -> x.refresh_token);
      GapiLens.set = (fun v x -> { x with refresh_token = v });
    }
end

type t =
  | ClientLoginAuthToken of ClientLogin.auth_token
  | ClientLoginCaptcha of ClientLogin.captcha
  | OAuth1RequestToken of OAuth1.request_token
  | OAuth1AuthorizeToken of OAuth1.auth_token
  | OAuth1GetAccessToken of OAuth1.access_token
  | AuthSubTokenInfo of AuthSub.token_info
  | OAuth2AuthCode of OAuth2.auth_code
  | OAuth2AccessToken of OAuth2.access_token

let client_login_auth_token =
  {
    GapiLens.get = (function ClientLoginAuthToken v -> Some v | _ -> None);
    GapiLens.set = (fun v _ -> ClientLoginAuthToken (Option.get v));
  }

let client_login_captcha =
  {
    GapiLens.get = (function ClientLoginCaptcha v -> Some v | _ -> None);
    GapiLens.set = (fun v _ -> ClientLoginCaptcha (Option.get v));
  }

let oauth1_request_token =
  {
    GapiLens.get = (function OAuth1RequestToken v -> Some v | _ -> None);
    GapiLens.set = (fun v _ -> OAuth1RequestToken (Option.get v));
  }

let oauth1_authorize_token =
  {
    GapiLens.get = (function OAuth1AuthorizeToken v -> Some v | _ -> None);
    GapiLens.set = (fun v _ -> OAuth1AuthorizeToken (Option.get v));
  }

let oauth1_get_access_token =
  {
    GapiLens.get = (function OAuth1GetAccessToken v -> Some v | _ -> None);
    GapiLens.set = (fun v _ -> OAuth1GetAccessToken (Option.get v));
  }

let auth_sub_token_info =
  {
    GapiLens.get = (function AuthSubTokenInfo v -> Some v | _ -> None);
    GapiLens.set = (fun v _ -> AuthSubTokenInfo (Option.get v));
  }

let oauth2_auth_code =
  {
    GapiLens.get = (function OAuth2AuthCode v -> Some v | _ -> None);
    GapiLens.set = (fun v _ -> OAuth2AuthCode (Option.get v));
  }

let oauth2_access_token =
  {
    GapiLens.get = (function OAuth2AccessToken v -> Some v | _ -> None);
    GapiLens.set = (fun v _ -> OAuth2AccessToken (Option.get v));
  }