kaggle 1.7.4.2__py3-none-any.whl → 1.8.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kaggle/__init__.py +10 -6
- kaggle/api/kaggle_api.py +574 -585
- kaggle/api/kaggle_api_extended.py +5251 -4738
- kaggle/cli.py +1335 -1585
- kaggle/models/api_blob_type.py +3 -3
- kaggle/models/dataset_column.py +129 -129
- kaggle/models/dataset_new_request.py +130 -72
- kaggle/models/dataset_new_version_request.py +88 -56
- kaggle/models/dataset_update_settings_request.py +93 -59
- kaggle/models/kaggle_models_extended.py +169 -172
- kaggle/models/kernel_push_request.py +152 -100
- kaggle/models/model_instance_new_version_request.py +30 -30
- kaggle/models/model_instance_update_request.py +171 -71
- kaggle/models/model_new_instance_request.py +223 -88
- kaggle/models/model_new_request.py +61 -46
- kaggle/models/model_update_request.py +66 -48
- kaggle/models/start_blob_upload_request.py +146 -138
- kaggle/models/start_blob_upload_response.py +83 -78
- kaggle/models/upload_file.py +92 -96
- kaggle/test/test_authenticate.py +23 -23
- {kaggle-1.7.4.2.dist-info → kaggle-1.8.0.dist-info}/METADATA +11 -15
- kaggle-1.8.0.dist-info/RECORD +148 -0
- kagglesdk/__init__.py +5 -1
- kagglesdk/benchmarks/services/__init__.py +0 -0
- kagglesdk/benchmarks/services/benchmarks_api_service.py +19 -0
- kagglesdk/benchmarks/types/__init__.py +0 -0
- kagglesdk/benchmarks/types/benchmark_types.py +307 -0
- kagglesdk/benchmarks/types/benchmarks_api_service.py +243 -0
- kagglesdk/blobs/services/blob_api_service.py +1 -1
- kagglesdk/blobs/types/blob_api_service.py +2 -2
- kagglesdk/common/services/__init__.py +0 -0
- kagglesdk/common/services/operations_service.py +46 -0
- kagglesdk/common/types/file_download.py +1 -1
- kagglesdk/common/types/http_redirect.py +1 -1
- kagglesdk/common/types/operations.py +194 -0
- kagglesdk/common/types/operations_service.py +48 -0
- kagglesdk/community/__init__.py +0 -0
- kagglesdk/community/types/__init__.py +0 -0
- kagglesdk/community/types/content_enums.py +44 -0
- kagglesdk/community/types/organization.py +410 -0
- kagglesdk/competitions/services/competition_api_service.py +49 -12
- kagglesdk/competitions/types/competition.py +14 -0
- kagglesdk/competitions/types/competition_api_service.py +1639 -1275
- kagglesdk/competitions/types/search_competitions.py +28 -0
- kagglesdk/datasets/databundles/__init__.py +0 -0
- kagglesdk/datasets/databundles/types/__init__.py +0 -0
- kagglesdk/datasets/databundles/types/databundle_api_types.py +540 -0
- kagglesdk/datasets/services/dataset_api_service.py +39 -14
- kagglesdk/datasets/types/dataset_api_service.py +567 -297
- kagglesdk/datasets/types/dataset_enums.py +21 -0
- kagglesdk/datasets/types/dataset_service.py +145 -0
- kagglesdk/datasets/types/dataset_types.py +74 -74
- kagglesdk/datasets/types/search_datasets.py +6 -0
- kagglesdk/discussions/__init__.py +0 -0
- kagglesdk/discussions/types/__init__.py +0 -0
- kagglesdk/discussions/types/search_discussions.py +43 -0
- kagglesdk/discussions/types/writeup_enums.py +11 -0
- kagglesdk/education/services/education_api_service.py +1 -1
- kagglesdk/education/types/education_api_service.py +1 -1
- kagglesdk/kaggle_client.py +55 -20
- kagglesdk/kaggle_creds.py +148 -0
- kagglesdk/kaggle_env.py +89 -27
- kagglesdk/kaggle_http_client.py +235 -290
- kagglesdk/kaggle_oauth.py +200 -0
- kagglesdk/kaggle_object.py +298 -250
- kagglesdk/kernels/services/kernels_api_service.py +46 -9
- kagglesdk/kernels/types/kernels_api_service.py +658 -158
- kagglesdk/kernels/types/kernels_enums.py +6 -0
- kagglesdk/kernels/types/search_kernels.py +6 -0
- kagglesdk/licenses/__init__.py +0 -0
- kagglesdk/licenses/types/__init__.py +0 -0
- kagglesdk/licenses/types/licenses_types.py +182 -0
- kagglesdk/models/services/model_api_service.py +46 -21
- kagglesdk/models/types/model_api_service.py +1018 -652
- kagglesdk/models/types/model_enums.py +8 -0
- kagglesdk/models/types/model_service.py +71 -71
- kagglesdk/models/types/model_types.py +1057 -5
- kagglesdk/models/types/search_models.py +8 -0
- kagglesdk/search/__init__.py +0 -0
- kagglesdk/search/services/__init__.py +0 -0
- kagglesdk/search/services/search_api_service.py +19 -0
- kagglesdk/search/types/__init__.py +0 -0
- kagglesdk/search/types/search_api_service.py +2435 -0
- kagglesdk/search/types/search_content_shared.py +50 -0
- kagglesdk/search/types/search_enums.py +45 -0
- kagglesdk/search/types/search_service.py +303 -0
- kagglesdk/security/__init__.py +0 -0
- kagglesdk/security/services/__init__.py +0 -0
- kagglesdk/security/services/iam_service.py +31 -0
- kagglesdk/security/services/oauth_service.py +58 -0
- kagglesdk/security/types/__init__.py +0 -0
- kagglesdk/security/types/authentication.py +171 -0
- kagglesdk/security/types/iam_service.py +496 -0
- kagglesdk/security/types/oauth_service.py +1181 -0
- kagglesdk/security/types/roles.py +8 -0
- kagglesdk/security/types/security_types.py +159 -0
- kagglesdk/test/__init__.py +0 -0
- kagglesdk/test/test_client.py +20 -24
- kagglesdk/users/services/__init__.py +0 -0
- kagglesdk/users/services/account_service.py +31 -0
- kagglesdk/users/services/group_api_service.py +31 -0
- kagglesdk/users/types/account_service.py +345 -0
- kagglesdk/users/types/group_api_service.py +315 -0
- kagglesdk/users/types/group_types.py +165 -0
- kagglesdk/users/types/groups_enum.py +8 -0
- kagglesdk/users/types/progression_service.py +9 -0
- kagglesdk/users/types/search_users.py +23 -0
- kagglesdk/users/types/user_avatar.py +226 -0
- kaggle/configuration.py +0 -206
- kaggle-1.7.4.2.dist-info/RECORD +0 -89
- {kaggle-1.7.4.2.dist-info → kaggle-1.8.0.dist-info}/WHEEL +0 -0
- {kaggle-1.7.4.2.dist-info → kaggle-1.8.0.dist-info}/entry_points.txt +0 -0
- {kaggle-1.7.4.2.dist-info → kaggle-1.8.0.dist-info}/licenses/LICENSE.txt +0 -0
- {kaggle/test → kagglesdk/benchmarks}/__init__.py +0 -0
|
@@ -0,0 +1,1181 @@
|
|
|
1
|
+
from kagglesdk.kaggle_object import *
|
|
2
|
+
from typing import Optional, List
|
|
3
|
+
|
|
4
|
+
class ExchangeOAuthTokenRequest(KaggleObject):
|
|
5
|
+
r"""
|
|
6
|
+
Attributes:
|
|
7
|
+
code (str)
|
|
8
|
+
Temporary OAuth code that was generated by the backend based on OAuth
|
|
9
|
+
parameters passed to the '/api/v1/oauth2/authorize' (StartOAuthFlowRequest)
|
|
10
|
+
endpoint. This is also known as OAuth flow token. It is sent to the flow
|
|
11
|
+
initiator as a query string parameter to their redirect_uri
|
|
12
|
+
(https://dataverse.org?code=808f9afcabb3489a8b30353a8ae4dc4b)
|
|
13
|
+
code_verifier (str)
|
|
14
|
+
Original code_verifier (hash of code_challenge) for PKCE protection.
|
|
15
|
+
grant_type (str)
|
|
16
|
+
Can be 'authorization_code' or 'refresh_token'.
|
|
17
|
+
client_id (str)
|
|
18
|
+
The client id of the OAuth client that initiated this flow.
|
|
19
|
+
redirect_uri (str)
|
|
20
|
+
The redirect URI that was used in the initial authorization request.
|
|
21
|
+
resource (str)
|
|
22
|
+
The 'resource' parameter is not part of the OAuth2 spec, but is sent by
|
|
23
|
+
some clients. We are capturing it here to avoid 'invalid field' errors.
|
|
24
|
+
refresh_token (str)
|
|
25
|
+
This field is used by MCP clients to refresh an access token. The client
|
|
26
|
+
sends a refresh_token to the standard /token endpoint, and this field
|
|
27
|
+
allows the server to correctly deserialize the request.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
def __init__(self):
|
|
31
|
+
self._code = None
|
|
32
|
+
self._code_verifier = None
|
|
33
|
+
self._grant_type = ""
|
|
34
|
+
self._client_id = None
|
|
35
|
+
self._redirect_uri = None
|
|
36
|
+
self._resource = None
|
|
37
|
+
self._refresh_token = None
|
|
38
|
+
self._freeze()
|
|
39
|
+
|
|
40
|
+
@property
|
|
41
|
+
def code(self) -> str:
|
|
42
|
+
r"""
|
|
43
|
+
Temporary OAuth code that was generated by the backend based on OAuth
|
|
44
|
+
parameters passed to the '/api/v1/oauth2/authorize' (StartOAuthFlowRequest)
|
|
45
|
+
endpoint. This is also known as OAuth flow token. It is sent to the flow
|
|
46
|
+
initiator as a query string parameter to their redirect_uri
|
|
47
|
+
(https://dataverse.org?code=808f9afcabb3489a8b30353a8ae4dc4b)
|
|
48
|
+
"""
|
|
49
|
+
return self._code or ""
|
|
50
|
+
|
|
51
|
+
@code.setter
|
|
52
|
+
def code(self, code: Optional[str]):
|
|
53
|
+
if code is None:
|
|
54
|
+
del self.code
|
|
55
|
+
return
|
|
56
|
+
if not isinstance(code, str):
|
|
57
|
+
raise TypeError('code must be of type str')
|
|
58
|
+
self._code = code
|
|
59
|
+
|
|
60
|
+
@property
|
|
61
|
+
def code_verifier(self) -> str:
|
|
62
|
+
"""Original code_verifier (hash of code_challenge) for PKCE protection."""
|
|
63
|
+
return self._code_verifier or ""
|
|
64
|
+
|
|
65
|
+
@code_verifier.setter
|
|
66
|
+
def code_verifier(self, code_verifier: Optional[str]):
|
|
67
|
+
if code_verifier is None:
|
|
68
|
+
del self.code_verifier
|
|
69
|
+
return
|
|
70
|
+
if not isinstance(code_verifier, str):
|
|
71
|
+
raise TypeError('code_verifier must be of type str')
|
|
72
|
+
self._code_verifier = code_verifier
|
|
73
|
+
|
|
74
|
+
@property
|
|
75
|
+
def grant_type(self) -> str:
|
|
76
|
+
"""Can be 'authorization_code' or 'refresh_token'."""
|
|
77
|
+
return self._grant_type
|
|
78
|
+
|
|
79
|
+
@grant_type.setter
|
|
80
|
+
def grant_type(self, grant_type: str):
|
|
81
|
+
if grant_type is None:
|
|
82
|
+
del self.grant_type
|
|
83
|
+
return
|
|
84
|
+
if not isinstance(grant_type, str):
|
|
85
|
+
raise TypeError('grant_type must be of type str')
|
|
86
|
+
self._grant_type = grant_type
|
|
87
|
+
|
|
88
|
+
@property
|
|
89
|
+
def client_id(self) -> str:
|
|
90
|
+
"""The client id of the OAuth client that initiated this flow."""
|
|
91
|
+
return self._client_id or ""
|
|
92
|
+
|
|
93
|
+
@client_id.setter
|
|
94
|
+
def client_id(self, client_id: Optional[str]):
|
|
95
|
+
if client_id is None:
|
|
96
|
+
del self.client_id
|
|
97
|
+
return
|
|
98
|
+
if not isinstance(client_id, str):
|
|
99
|
+
raise TypeError('client_id must be of type str')
|
|
100
|
+
self._client_id = client_id
|
|
101
|
+
|
|
102
|
+
@property
|
|
103
|
+
def redirect_uri(self) -> str:
|
|
104
|
+
"""The redirect URI that was used in the initial authorization request."""
|
|
105
|
+
return self._redirect_uri or ""
|
|
106
|
+
|
|
107
|
+
@redirect_uri.setter
|
|
108
|
+
def redirect_uri(self, redirect_uri: Optional[str]):
|
|
109
|
+
if redirect_uri is None:
|
|
110
|
+
del self.redirect_uri
|
|
111
|
+
return
|
|
112
|
+
if not isinstance(redirect_uri, str):
|
|
113
|
+
raise TypeError('redirect_uri must be of type str')
|
|
114
|
+
self._redirect_uri = redirect_uri
|
|
115
|
+
|
|
116
|
+
@property
|
|
117
|
+
def resource(self) -> str:
|
|
118
|
+
r"""
|
|
119
|
+
The 'resource' parameter is not part of the OAuth2 spec, but is sent by
|
|
120
|
+
some clients. We are capturing it here to avoid 'invalid field' errors.
|
|
121
|
+
"""
|
|
122
|
+
return self._resource or ""
|
|
123
|
+
|
|
124
|
+
@resource.setter
|
|
125
|
+
def resource(self, resource: Optional[str]):
|
|
126
|
+
if resource is None:
|
|
127
|
+
del self.resource
|
|
128
|
+
return
|
|
129
|
+
if not isinstance(resource, str):
|
|
130
|
+
raise TypeError('resource must be of type str')
|
|
131
|
+
self._resource = resource
|
|
132
|
+
|
|
133
|
+
@property
|
|
134
|
+
def refresh_token(self) -> str:
|
|
135
|
+
r"""
|
|
136
|
+
This field is used by MCP clients to refresh an access token. The client
|
|
137
|
+
sends a refresh_token to the standard /token endpoint, and this field
|
|
138
|
+
allows the server to correctly deserialize the request.
|
|
139
|
+
"""
|
|
140
|
+
return self._refresh_token or ""
|
|
141
|
+
|
|
142
|
+
@refresh_token.setter
|
|
143
|
+
def refresh_token(self, refresh_token: Optional[str]):
|
|
144
|
+
if refresh_token is None:
|
|
145
|
+
del self.refresh_token
|
|
146
|
+
return
|
|
147
|
+
if not isinstance(refresh_token, str):
|
|
148
|
+
raise TypeError('refresh_token must be of type str')
|
|
149
|
+
self._refresh_token = refresh_token
|
|
150
|
+
|
|
151
|
+
def endpoint(self):
|
|
152
|
+
path = '/api/v1/oauth2/token'
|
|
153
|
+
return path.format_map(self.to_field_map(self))
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
@staticmethod
|
|
157
|
+
def method():
|
|
158
|
+
return 'POST'
|
|
159
|
+
|
|
160
|
+
@staticmethod
|
|
161
|
+
def body_fields():
|
|
162
|
+
return '*'
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
class ExchangeOAuthTokenResponse(KaggleObject):
|
|
166
|
+
r"""
|
|
167
|
+
Attributes:
|
|
168
|
+
access_token (str)
|
|
169
|
+
Short-lived access token.
|
|
170
|
+
refresh_token (str)
|
|
171
|
+
Long-lived refresh token that can be used to generate access tokens using
|
|
172
|
+
the '/api/v1/access-tokens/generate' (GenerateAccessTokenRequest) endpoint.
|
|
173
|
+
token_type (str)
|
|
174
|
+
Type of the token. Set to 'Bearer'.
|
|
175
|
+
expires_in (int)
|
|
176
|
+
Lifetime of the access token in seconds.
|
|
177
|
+
username (str)
|
|
178
|
+
Username of the user who authorized/owns this token.
|
|
179
|
+
user_id (int)
|
|
180
|
+
Id the of user who authorized/owns this token.
|
|
181
|
+
scope (str)
|
|
182
|
+
The scope of the access token as a space-delimited list of strings.
|
|
183
|
+
"""
|
|
184
|
+
|
|
185
|
+
def __init__(self):
|
|
186
|
+
self._access_token = ""
|
|
187
|
+
self._refresh_token = ""
|
|
188
|
+
self._token_type = ""
|
|
189
|
+
self._expires_in = 0
|
|
190
|
+
self._username = ""
|
|
191
|
+
self._user_id = 0
|
|
192
|
+
self._scope = None
|
|
193
|
+
self._freeze()
|
|
194
|
+
|
|
195
|
+
@property
|
|
196
|
+
def access_token(self) -> str:
|
|
197
|
+
"""Short-lived access token."""
|
|
198
|
+
return self._access_token
|
|
199
|
+
|
|
200
|
+
@access_token.setter
|
|
201
|
+
def access_token(self, access_token: str):
|
|
202
|
+
if access_token is None:
|
|
203
|
+
del self.access_token
|
|
204
|
+
return
|
|
205
|
+
if not isinstance(access_token, str):
|
|
206
|
+
raise TypeError('access_token must be of type str')
|
|
207
|
+
self._access_token = access_token
|
|
208
|
+
|
|
209
|
+
@property
|
|
210
|
+
def refresh_token(self) -> str:
|
|
211
|
+
r"""
|
|
212
|
+
Long-lived refresh token that can be used to generate access tokens using
|
|
213
|
+
the '/api/v1/access-tokens/generate' (GenerateAccessTokenRequest) endpoint.
|
|
214
|
+
"""
|
|
215
|
+
return self._refresh_token
|
|
216
|
+
|
|
217
|
+
@refresh_token.setter
|
|
218
|
+
def refresh_token(self, refresh_token: str):
|
|
219
|
+
if refresh_token is None:
|
|
220
|
+
del self.refresh_token
|
|
221
|
+
return
|
|
222
|
+
if not isinstance(refresh_token, str):
|
|
223
|
+
raise TypeError('refresh_token must be of type str')
|
|
224
|
+
self._refresh_token = refresh_token
|
|
225
|
+
|
|
226
|
+
@property
|
|
227
|
+
def token_type(self) -> str:
|
|
228
|
+
"""Type of the token. Set to 'Bearer'."""
|
|
229
|
+
return self._token_type
|
|
230
|
+
|
|
231
|
+
@token_type.setter
|
|
232
|
+
def token_type(self, token_type: str):
|
|
233
|
+
if token_type is None:
|
|
234
|
+
del self.token_type
|
|
235
|
+
return
|
|
236
|
+
if not isinstance(token_type, str):
|
|
237
|
+
raise TypeError('token_type must be of type str')
|
|
238
|
+
self._token_type = token_type
|
|
239
|
+
|
|
240
|
+
@property
|
|
241
|
+
def expires_in(self) -> int:
|
|
242
|
+
"""Lifetime of the access token in seconds."""
|
|
243
|
+
return self._expires_in
|
|
244
|
+
|
|
245
|
+
@expires_in.setter
|
|
246
|
+
def expires_in(self, expires_in: int):
|
|
247
|
+
if expires_in is None:
|
|
248
|
+
del self.expires_in
|
|
249
|
+
return
|
|
250
|
+
if not isinstance(expires_in, int):
|
|
251
|
+
raise TypeError('expires_in must be of type int')
|
|
252
|
+
self._expires_in = expires_in
|
|
253
|
+
|
|
254
|
+
@property
|
|
255
|
+
def username(self) -> str:
|
|
256
|
+
"""Username of the user who authorized/owns this token."""
|
|
257
|
+
return self._username
|
|
258
|
+
|
|
259
|
+
@username.setter
|
|
260
|
+
def username(self, username: str):
|
|
261
|
+
if username is None:
|
|
262
|
+
del self.username
|
|
263
|
+
return
|
|
264
|
+
if not isinstance(username, str):
|
|
265
|
+
raise TypeError('username must be of type str')
|
|
266
|
+
self._username = username
|
|
267
|
+
|
|
268
|
+
@property
|
|
269
|
+
def user_id(self) -> int:
|
|
270
|
+
"""Id the of user who authorized/owns this token."""
|
|
271
|
+
return self._user_id
|
|
272
|
+
|
|
273
|
+
@user_id.setter
|
|
274
|
+
def user_id(self, user_id: int):
|
|
275
|
+
if user_id is None:
|
|
276
|
+
del self.user_id
|
|
277
|
+
return
|
|
278
|
+
if not isinstance(user_id, int):
|
|
279
|
+
raise TypeError('user_id must be of type int')
|
|
280
|
+
self._user_id = user_id
|
|
281
|
+
|
|
282
|
+
@property
|
|
283
|
+
def scope(self) -> str:
|
|
284
|
+
"""The scope of the access token as a space-delimited list of strings."""
|
|
285
|
+
return self._scope or ""
|
|
286
|
+
|
|
287
|
+
@scope.setter
|
|
288
|
+
def scope(self, scope: Optional[str]):
|
|
289
|
+
if scope is None:
|
|
290
|
+
del self.scope
|
|
291
|
+
return
|
|
292
|
+
if not isinstance(scope, str):
|
|
293
|
+
raise TypeError('scope must be of type str')
|
|
294
|
+
self._scope = scope
|
|
295
|
+
|
|
296
|
+
@property
|
|
297
|
+
def accessToken(self):
|
|
298
|
+
return self.access_token
|
|
299
|
+
|
|
300
|
+
@property
|
|
301
|
+
def refreshToken(self):
|
|
302
|
+
return self.refresh_token
|
|
303
|
+
|
|
304
|
+
@property
|
|
305
|
+
def tokenType(self):
|
|
306
|
+
return self.token_type
|
|
307
|
+
|
|
308
|
+
@property
|
|
309
|
+
def expiresIn(self):
|
|
310
|
+
return self.expires_in
|
|
311
|
+
|
|
312
|
+
@property
|
|
313
|
+
def userId(self):
|
|
314
|
+
return self.user_id
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
class IntrospectTokenRequest(KaggleObject):
|
|
318
|
+
r"""
|
|
319
|
+
Attributes:
|
|
320
|
+
token (str)
|
|
321
|
+
Token to introspect (access token or refresh token), returned in the
|
|
322
|
+
response of '/api/v1/oauth2/token' (ExchangeOAuthToken) RPC.
|
|
323
|
+
"""
|
|
324
|
+
|
|
325
|
+
def __init__(self):
|
|
326
|
+
self._token = ""
|
|
327
|
+
self._freeze()
|
|
328
|
+
|
|
329
|
+
@property
|
|
330
|
+
def token(self) -> str:
|
|
331
|
+
r"""
|
|
332
|
+
Token to introspect (access token or refresh token), returned in the
|
|
333
|
+
response of '/api/v1/oauth2/token' (ExchangeOAuthToken) RPC.
|
|
334
|
+
"""
|
|
335
|
+
return self._token
|
|
336
|
+
|
|
337
|
+
@token.setter
|
|
338
|
+
def token(self, token: str):
|
|
339
|
+
if token is None:
|
|
340
|
+
del self.token
|
|
341
|
+
return
|
|
342
|
+
if not isinstance(token, str):
|
|
343
|
+
raise TypeError('token must be of type str')
|
|
344
|
+
self._token = token
|
|
345
|
+
|
|
346
|
+
def endpoint(self):
|
|
347
|
+
path = '/api/v1/oauth2/introspect'
|
|
348
|
+
return path.format_map(self.to_field_map(self))
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
@staticmethod
|
|
352
|
+
def method():
|
|
353
|
+
return 'POST'
|
|
354
|
+
|
|
355
|
+
@staticmethod
|
|
356
|
+
def body_fields():
|
|
357
|
+
return '*'
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
class IntrospectTokenResponse(KaggleObject):
|
|
361
|
+
r"""
|
|
362
|
+
Attributes:
|
|
363
|
+
active (bool)
|
|
364
|
+
Indicates if the token is active, i.e., not revoked nor expired.
|
|
365
|
+
client_id (str)
|
|
366
|
+
The client identifier for the OAuth 2.0 client that the token was issued
|
|
367
|
+
to.
|
|
368
|
+
username (str)
|
|
369
|
+
Username of the user who authorized this token.
|
|
370
|
+
user_id (int)
|
|
371
|
+
Id of the user who authorized this token.
|
|
372
|
+
scope (str)
|
|
373
|
+
Space-separated list of scopes.
|
|
374
|
+
exp (int)
|
|
375
|
+
The unix timestamp indicating when this token will expire.
|
|
376
|
+
"""
|
|
377
|
+
|
|
378
|
+
def __init__(self):
|
|
379
|
+
self._active = False
|
|
380
|
+
self._client_id = ""
|
|
381
|
+
self._username = ""
|
|
382
|
+
self._user_id = None
|
|
383
|
+
self._scope = ""
|
|
384
|
+
self._exp = None
|
|
385
|
+
self._freeze()
|
|
386
|
+
|
|
387
|
+
@property
|
|
388
|
+
def active(self) -> bool:
|
|
389
|
+
"""Indicates if the token is active, i.e., not revoked nor expired."""
|
|
390
|
+
return self._active
|
|
391
|
+
|
|
392
|
+
@active.setter
|
|
393
|
+
def active(self, active: bool):
|
|
394
|
+
if active is None:
|
|
395
|
+
del self.active
|
|
396
|
+
return
|
|
397
|
+
if not isinstance(active, bool):
|
|
398
|
+
raise TypeError('active must be of type bool')
|
|
399
|
+
self._active = active
|
|
400
|
+
|
|
401
|
+
@property
|
|
402
|
+
def client_id(self) -> str:
|
|
403
|
+
r"""
|
|
404
|
+
The client identifier for the OAuth 2.0 client that the token was issued
|
|
405
|
+
to.
|
|
406
|
+
"""
|
|
407
|
+
return self._client_id
|
|
408
|
+
|
|
409
|
+
@client_id.setter
|
|
410
|
+
def client_id(self, client_id: str):
|
|
411
|
+
if client_id is None:
|
|
412
|
+
del self.client_id
|
|
413
|
+
return
|
|
414
|
+
if not isinstance(client_id, str):
|
|
415
|
+
raise TypeError('client_id must be of type str')
|
|
416
|
+
self._client_id = client_id
|
|
417
|
+
|
|
418
|
+
@property
|
|
419
|
+
def username(self) -> str:
|
|
420
|
+
"""Username of the user who authorized this token."""
|
|
421
|
+
return self._username
|
|
422
|
+
|
|
423
|
+
@username.setter
|
|
424
|
+
def username(self, username: str):
|
|
425
|
+
if username is None:
|
|
426
|
+
del self.username
|
|
427
|
+
return
|
|
428
|
+
if not isinstance(username, str):
|
|
429
|
+
raise TypeError('username must be of type str')
|
|
430
|
+
self._username = username
|
|
431
|
+
|
|
432
|
+
@property
|
|
433
|
+
def user_id(self) -> int:
|
|
434
|
+
"""Id of the user who authorized this token."""
|
|
435
|
+
return self._user_id or 0
|
|
436
|
+
|
|
437
|
+
@user_id.setter
|
|
438
|
+
def user_id(self, user_id: Optional[int]):
|
|
439
|
+
if user_id is None:
|
|
440
|
+
del self.user_id
|
|
441
|
+
return
|
|
442
|
+
if not isinstance(user_id, int):
|
|
443
|
+
raise TypeError('user_id must be of type int')
|
|
444
|
+
self._user_id = user_id
|
|
445
|
+
|
|
446
|
+
@property
|
|
447
|
+
def scope(self) -> str:
|
|
448
|
+
"""Space-separated list of scopes."""
|
|
449
|
+
return self._scope
|
|
450
|
+
|
|
451
|
+
@scope.setter
|
|
452
|
+
def scope(self, scope: str):
|
|
453
|
+
if scope is None:
|
|
454
|
+
del self.scope
|
|
455
|
+
return
|
|
456
|
+
if not isinstance(scope, str):
|
|
457
|
+
raise TypeError('scope must be of type str')
|
|
458
|
+
self._scope = scope
|
|
459
|
+
|
|
460
|
+
@property
|
|
461
|
+
def exp(self) -> int:
|
|
462
|
+
"""The unix timestamp indicating when this token will expire."""
|
|
463
|
+
return self._exp or 0
|
|
464
|
+
|
|
465
|
+
@exp.setter
|
|
466
|
+
def exp(self, exp: Optional[int]):
|
|
467
|
+
if exp is None:
|
|
468
|
+
del self.exp
|
|
469
|
+
return
|
|
470
|
+
if not isinstance(exp, int):
|
|
471
|
+
raise TypeError('exp must be of type int')
|
|
472
|
+
self._exp = exp
|
|
473
|
+
|
|
474
|
+
@property
|
|
475
|
+
def clientId(self):
|
|
476
|
+
return self.client_id
|
|
477
|
+
|
|
478
|
+
@property
|
|
479
|
+
def userId(self):
|
|
480
|
+
return self.user_id
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
class RegisterOAuthClientRequest(KaggleObject):
|
|
484
|
+
r"""
|
|
485
|
+
Attributes:
|
|
486
|
+
client_name (str)
|
|
487
|
+
Human-readable name for the client (e.g., 'Gemini CLI MCP Client')
|
|
488
|
+
redirect_uris (str)
|
|
489
|
+
Array of redirect URIs the client will use (e.g.,
|
|
490
|
+
'http://localhost:7777/oauth/callback')
|
|
491
|
+
grant_types (str)
|
|
492
|
+
Array of OAuth 2.0 grant types the client requests (expected:
|
|
493
|
+
authorization_code, refresh_token)
|
|
494
|
+
token_endpoint_auth_method (str)
|
|
495
|
+
Client Authentication method (expected: 'none')
|
|
496
|
+
scope (str)
|
|
497
|
+
Space-separated list of scopes the client would like to use
|
|
498
|
+
code_challenge_method (str)
|
|
499
|
+
Array of supported PKCE methods (expected: 'S256')
|
|
500
|
+
"""
|
|
501
|
+
|
|
502
|
+
def __init__(self):
|
|
503
|
+
self._client_name = ""
|
|
504
|
+
self._redirect_uris = []
|
|
505
|
+
self._grant_types = []
|
|
506
|
+
self._token_endpoint_auth_method = ""
|
|
507
|
+
self._scope = None
|
|
508
|
+
self._code_challenge_method = []
|
|
509
|
+
self._freeze()
|
|
510
|
+
|
|
511
|
+
@property
|
|
512
|
+
def client_name(self) -> str:
|
|
513
|
+
"""Human-readable name for the client (e.g., 'Gemini CLI MCP Client')"""
|
|
514
|
+
return self._client_name
|
|
515
|
+
|
|
516
|
+
@client_name.setter
|
|
517
|
+
def client_name(self, client_name: str):
|
|
518
|
+
if client_name is None:
|
|
519
|
+
del self.client_name
|
|
520
|
+
return
|
|
521
|
+
if not isinstance(client_name, str):
|
|
522
|
+
raise TypeError('client_name must be of type str')
|
|
523
|
+
self._client_name = client_name
|
|
524
|
+
|
|
525
|
+
@property
|
|
526
|
+
def redirect_uris(self) -> Optional[List[str]]:
|
|
527
|
+
r"""
|
|
528
|
+
Array of redirect URIs the client will use (e.g.,
|
|
529
|
+
'http://localhost:7777/oauth/callback')
|
|
530
|
+
"""
|
|
531
|
+
return self._redirect_uris
|
|
532
|
+
|
|
533
|
+
@redirect_uris.setter
|
|
534
|
+
def redirect_uris(self, redirect_uris: Optional[List[str]]):
|
|
535
|
+
if redirect_uris is None:
|
|
536
|
+
del self.redirect_uris
|
|
537
|
+
return
|
|
538
|
+
if not isinstance(redirect_uris, list):
|
|
539
|
+
raise TypeError('redirect_uris must be of type list')
|
|
540
|
+
if not all([isinstance(t, str) for t in redirect_uris]):
|
|
541
|
+
raise TypeError('redirect_uris must contain only items of type str')
|
|
542
|
+
self._redirect_uris = redirect_uris
|
|
543
|
+
|
|
544
|
+
@property
|
|
545
|
+
def grant_types(self) -> Optional[List[str]]:
|
|
546
|
+
r"""
|
|
547
|
+
Array of OAuth 2.0 grant types the client requests (expected:
|
|
548
|
+
authorization_code, refresh_token)
|
|
549
|
+
"""
|
|
550
|
+
return self._grant_types
|
|
551
|
+
|
|
552
|
+
@grant_types.setter
|
|
553
|
+
def grant_types(self, grant_types: Optional[List[str]]):
|
|
554
|
+
if grant_types is None:
|
|
555
|
+
del self.grant_types
|
|
556
|
+
return
|
|
557
|
+
if not isinstance(grant_types, list):
|
|
558
|
+
raise TypeError('grant_types must be of type list')
|
|
559
|
+
if not all([isinstance(t, str) for t in grant_types]):
|
|
560
|
+
raise TypeError('grant_types must contain only items of type str')
|
|
561
|
+
self._grant_types = grant_types
|
|
562
|
+
|
|
563
|
+
@property
|
|
564
|
+
def token_endpoint_auth_method(self) -> str:
|
|
565
|
+
"""Client Authentication method (expected: 'none')"""
|
|
566
|
+
return self._token_endpoint_auth_method
|
|
567
|
+
|
|
568
|
+
@token_endpoint_auth_method.setter
|
|
569
|
+
def token_endpoint_auth_method(self, token_endpoint_auth_method: str):
|
|
570
|
+
if token_endpoint_auth_method is None:
|
|
571
|
+
del self.token_endpoint_auth_method
|
|
572
|
+
return
|
|
573
|
+
if not isinstance(token_endpoint_auth_method, str):
|
|
574
|
+
raise TypeError('token_endpoint_auth_method must be of type str')
|
|
575
|
+
self._token_endpoint_auth_method = token_endpoint_auth_method
|
|
576
|
+
|
|
577
|
+
@property
|
|
578
|
+
def scope(self) -> str:
|
|
579
|
+
"""Space-separated list of scopes the client would like to use"""
|
|
580
|
+
return self._scope or ""
|
|
581
|
+
|
|
582
|
+
@scope.setter
|
|
583
|
+
def scope(self, scope: Optional[str]):
|
|
584
|
+
if scope is None:
|
|
585
|
+
del self.scope
|
|
586
|
+
return
|
|
587
|
+
if not isinstance(scope, str):
|
|
588
|
+
raise TypeError('scope must be of type str')
|
|
589
|
+
self._scope = scope
|
|
590
|
+
|
|
591
|
+
@property
|
|
592
|
+
def code_challenge_method(self) -> Optional[List[str]]:
|
|
593
|
+
"""Array of supported PKCE methods (expected: 'S256')"""
|
|
594
|
+
return self._code_challenge_method
|
|
595
|
+
|
|
596
|
+
@code_challenge_method.setter
|
|
597
|
+
def code_challenge_method(self, code_challenge_method: Optional[List[str]]):
|
|
598
|
+
if code_challenge_method is None:
|
|
599
|
+
del self.code_challenge_method
|
|
600
|
+
return
|
|
601
|
+
if not isinstance(code_challenge_method, list):
|
|
602
|
+
raise TypeError('code_challenge_method must be of type list')
|
|
603
|
+
if not all([isinstance(t, str) for t in code_challenge_method]):
|
|
604
|
+
raise TypeError('code_challenge_method must contain only items of type str')
|
|
605
|
+
self._code_challenge_method = code_challenge_method
|
|
606
|
+
|
|
607
|
+
def endpoint(self):
|
|
608
|
+
path = '/api/v1/oauth2/register'
|
|
609
|
+
return path.format_map(self.to_field_map(self))
|
|
610
|
+
|
|
611
|
+
|
|
612
|
+
@staticmethod
|
|
613
|
+
def method():
|
|
614
|
+
return 'POST'
|
|
615
|
+
|
|
616
|
+
@staticmethod
|
|
617
|
+
def body_fields():
|
|
618
|
+
return '*'
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
class RegisterOAuthClientResponse(KaggleObject):
|
|
622
|
+
r"""
|
|
623
|
+
According to RFC 7591 &&
|
|
624
|
+
https://github.com/google-gemini/gemini-cli/blob/56f394cefd04696a5192fef9bbff8ba0e5b0583f/packages/core/src/mcp/oauth-provider.ts#L69
|
|
625
|
+
|
|
626
|
+
Attributes:
|
|
627
|
+
client_id (str)
|
|
628
|
+
redirect_uris (str)
|
|
629
|
+
grant_types (str)
|
|
630
|
+
response_types (str)
|
|
631
|
+
token_endpoint_auth_method (str)
|
|
632
|
+
scope (str)
|
|
633
|
+
authorization_url (str)
|
|
634
|
+
token_url (str)
|
|
635
|
+
client_secret (str)
|
|
636
|
+
client_id_issued_at (int)
|
|
637
|
+
client_secret_expires_at (int)
|
|
638
|
+
revocation_url (str)
|
|
639
|
+
userinfo_url (str)
|
|
640
|
+
code_challenge_methods_supported (str)
|
|
641
|
+
"""
|
|
642
|
+
|
|
643
|
+
def __init__(self):
|
|
644
|
+
self._client_id = ""
|
|
645
|
+
self._redirect_uris = []
|
|
646
|
+
self._grant_types = []
|
|
647
|
+
self._response_types = []
|
|
648
|
+
self._token_endpoint_auth_method = ""
|
|
649
|
+
self._scope = None
|
|
650
|
+
self._authorization_url = None
|
|
651
|
+
self._token_url = None
|
|
652
|
+
self._client_secret = None
|
|
653
|
+
self._client_id_issued_at = None
|
|
654
|
+
self._client_secret_expires_at = None
|
|
655
|
+
self._revocation_url = None
|
|
656
|
+
self._userinfo_url = None
|
|
657
|
+
self._code_challenge_methods_supported = []
|
|
658
|
+
self._freeze()
|
|
659
|
+
|
|
660
|
+
@property
|
|
661
|
+
def client_id(self) -> str:
|
|
662
|
+
return self._client_id
|
|
663
|
+
|
|
664
|
+
@client_id.setter
|
|
665
|
+
def client_id(self, client_id: str):
|
|
666
|
+
if client_id is None:
|
|
667
|
+
del self.client_id
|
|
668
|
+
return
|
|
669
|
+
if not isinstance(client_id, str):
|
|
670
|
+
raise TypeError('client_id must be of type str')
|
|
671
|
+
self._client_id = client_id
|
|
672
|
+
|
|
673
|
+
@property
|
|
674
|
+
def redirect_uris(self) -> Optional[List[str]]:
|
|
675
|
+
return self._redirect_uris
|
|
676
|
+
|
|
677
|
+
@redirect_uris.setter
|
|
678
|
+
def redirect_uris(self, redirect_uris: Optional[List[str]]):
|
|
679
|
+
if redirect_uris is None:
|
|
680
|
+
del self.redirect_uris
|
|
681
|
+
return
|
|
682
|
+
if not isinstance(redirect_uris, list):
|
|
683
|
+
raise TypeError('redirect_uris must be of type list')
|
|
684
|
+
if not all([isinstance(t, str) for t in redirect_uris]):
|
|
685
|
+
raise TypeError('redirect_uris must contain only items of type str')
|
|
686
|
+
self._redirect_uris = redirect_uris
|
|
687
|
+
|
|
688
|
+
@property
|
|
689
|
+
def grant_types(self) -> Optional[List[str]]:
|
|
690
|
+
return self._grant_types
|
|
691
|
+
|
|
692
|
+
@grant_types.setter
|
|
693
|
+
def grant_types(self, grant_types: Optional[List[str]]):
|
|
694
|
+
if grant_types is None:
|
|
695
|
+
del self.grant_types
|
|
696
|
+
return
|
|
697
|
+
if not isinstance(grant_types, list):
|
|
698
|
+
raise TypeError('grant_types must be of type list')
|
|
699
|
+
if not all([isinstance(t, str) for t in grant_types]):
|
|
700
|
+
raise TypeError('grant_types must contain only items of type str')
|
|
701
|
+
self._grant_types = grant_types
|
|
702
|
+
|
|
703
|
+
@property
|
|
704
|
+
def response_types(self) -> Optional[List[str]]:
|
|
705
|
+
return self._response_types
|
|
706
|
+
|
|
707
|
+
@response_types.setter
|
|
708
|
+
def response_types(self, response_types: Optional[List[str]]):
|
|
709
|
+
if response_types is None:
|
|
710
|
+
del self.response_types
|
|
711
|
+
return
|
|
712
|
+
if not isinstance(response_types, list):
|
|
713
|
+
raise TypeError('response_types must be of type list')
|
|
714
|
+
if not all([isinstance(t, str) for t in response_types]):
|
|
715
|
+
raise TypeError('response_types must contain only items of type str')
|
|
716
|
+
self._response_types = response_types
|
|
717
|
+
|
|
718
|
+
@property
|
|
719
|
+
def token_endpoint_auth_method(self) -> str:
|
|
720
|
+
return self._token_endpoint_auth_method
|
|
721
|
+
|
|
722
|
+
@token_endpoint_auth_method.setter
|
|
723
|
+
def token_endpoint_auth_method(self, token_endpoint_auth_method: str):
|
|
724
|
+
if token_endpoint_auth_method is None:
|
|
725
|
+
del self.token_endpoint_auth_method
|
|
726
|
+
return
|
|
727
|
+
if not isinstance(token_endpoint_auth_method, str):
|
|
728
|
+
raise TypeError('token_endpoint_auth_method must be of type str')
|
|
729
|
+
self._token_endpoint_auth_method = token_endpoint_auth_method
|
|
730
|
+
|
|
731
|
+
@property
|
|
732
|
+
def scope(self) -> str:
|
|
733
|
+
return self._scope or ""
|
|
734
|
+
|
|
735
|
+
@scope.setter
|
|
736
|
+
def scope(self, scope: Optional[str]):
|
|
737
|
+
if scope is None:
|
|
738
|
+
del self.scope
|
|
739
|
+
return
|
|
740
|
+
if not isinstance(scope, str):
|
|
741
|
+
raise TypeError('scope must be of type str')
|
|
742
|
+
self._scope = scope
|
|
743
|
+
|
|
744
|
+
@property
|
|
745
|
+
def authorization_url(self) -> str:
|
|
746
|
+
return self._authorization_url or ""
|
|
747
|
+
|
|
748
|
+
@authorization_url.setter
|
|
749
|
+
def authorization_url(self, authorization_url: Optional[str]):
|
|
750
|
+
if authorization_url is None:
|
|
751
|
+
del self.authorization_url
|
|
752
|
+
return
|
|
753
|
+
if not isinstance(authorization_url, str):
|
|
754
|
+
raise TypeError('authorization_url must be of type str')
|
|
755
|
+
self._authorization_url = authorization_url
|
|
756
|
+
|
|
757
|
+
@property
|
|
758
|
+
def token_url(self) -> str:
|
|
759
|
+
return self._token_url or ""
|
|
760
|
+
|
|
761
|
+
@token_url.setter
|
|
762
|
+
def token_url(self, token_url: Optional[str]):
|
|
763
|
+
if token_url is None:
|
|
764
|
+
del self.token_url
|
|
765
|
+
return
|
|
766
|
+
if not isinstance(token_url, str):
|
|
767
|
+
raise TypeError('token_url must be of type str')
|
|
768
|
+
self._token_url = token_url
|
|
769
|
+
|
|
770
|
+
@property
|
|
771
|
+
def revocation_url(self) -> str:
|
|
772
|
+
return self._revocation_url or ""
|
|
773
|
+
|
|
774
|
+
@revocation_url.setter
|
|
775
|
+
def revocation_url(self, revocation_url: Optional[str]):
|
|
776
|
+
if revocation_url is None:
|
|
777
|
+
del self.revocation_url
|
|
778
|
+
return
|
|
779
|
+
if not isinstance(revocation_url, str):
|
|
780
|
+
raise TypeError('revocation_url must be of type str')
|
|
781
|
+
self._revocation_url = revocation_url
|
|
782
|
+
|
|
783
|
+
@property
|
|
784
|
+
def userinfo_url(self) -> str:
|
|
785
|
+
return self._userinfo_url or ""
|
|
786
|
+
|
|
787
|
+
@userinfo_url.setter
|
|
788
|
+
def userinfo_url(self, userinfo_url: Optional[str]):
|
|
789
|
+
if userinfo_url is None:
|
|
790
|
+
del self.userinfo_url
|
|
791
|
+
return
|
|
792
|
+
if not isinstance(userinfo_url, str):
|
|
793
|
+
raise TypeError('userinfo_url must be of type str')
|
|
794
|
+
self._userinfo_url = userinfo_url
|
|
795
|
+
|
|
796
|
+
@property
|
|
797
|
+
def code_challenge_methods_supported(self) -> Optional[List[str]]:
|
|
798
|
+
return self._code_challenge_methods_supported
|
|
799
|
+
|
|
800
|
+
@code_challenge_methods_supported.setter
|
|
801
|
+
def code_challenge_methods_supported(self, code_challenge_methods_supported: Optional[List[str]]):
|
|
802
|
+
if code_challenge_methods_supported is None:
|
|
803
|
+
del self.code_challenge_methods_supported
|
|
804
|
+
return
|
|
805
|
+
if not isinstance(code_challenge_methods_supported, list):
|
|
806
|
+
raise TypeError('code_challenge_methods_supported must be of type list')
|
|
807
|
+
if not all([isinstance(t, str) for t in code_challenge_methods_supported]):
|
|
808
|
+
raise TypeError('code_challenge_methods_supported must contain only items of type str')
|
|
809
|
+
self._code_challenge_methods_supported = code_challenge_methods_supported
|
|
810
|
+
|
|
811
|
+
@property
|
|
812
|
+
def client_secret(self) -> str:
|
|
813
|
+
return self._client_secret or ""
|
|
814
|
+
|
|
815
|
+
@client_secret.setter
|
|
816
|
+
def client_secret(self, client_secret: Optional[str]):
|
|
817
|
+
if client_secret is None:
|
|
818
|
+
del self.client_secret
|
|
819
|
+
return
|
|
820
|
+
if not isinstance(client_secret, str):
|
|
821
|
+
raise TypeError('client_secret must be of type str')
|
|
822
|
+
self._client_secret = client_secret
|
|
823
|
+
|
|
824
|
+
@property
|
|
825
|
+
def client_id_issued_at(self) -> int:
|
|
826
|
+
return self._client_id_issued_at or 0
|
|
827
|
+
|
|
828
|
+
@client_id_issued_at.setter
|
|
829
|
+
def client_id_issued_at(self, client_id_issued_at: Optional[int]):
|
|
830
|
+
if client_id_issued_at is None:
|
|
831
|
+
del self.client_id_issued_at
|
|
832
|
+
return
|
|
833
|
+
if not isinstance(client_id_issued_at, int):
|
|
834
|
+
raise TypeError('client_id_issued_at must be of type int')
|
|
835
|
+
self._client_id_issued_at = client_id_issued_at
|
|
836
|
+
|
|
837
|
+
@property
|
|
838
|
+
def client_secret_expires_at(self) -> int:
|
|
839
|
+
return self._client_secret_expires_at or 0
|
|
840
|
+
|
|
841
|
+
@client_secret_expires_at.setter
|
|
842
|
+
def client_secret_expires_at(self, client_secret_expires_at: Optional[int]):
|
|
843
|
+
if client_secret_expires_at is None:
|
|
844
|
+
del self.client_secret_expires_at
|
|
845
|
+
return
|
|
846
|
+
if not isinstance(client_secret_expires_at, int):
|
|
847
|
+
raise TypeError('client_secret_expires_at must be of type int')
|
|
848
|
+
self._client_secret_expires_at = client_secret_expires_at
|
|
849
|
+
|
|
850
|
+
@property
|
|
851
|
+
def clientId(self):
|
|
852
|
+
return self.client_id
|
|
853
|
+
|
|
854
|
+
@property
|
|
855
|
+
def redirectUris(self):
|
|
856
|
+
return self.redirect_uris
|
|
857
|
+
|
|
858
|
+
@property
|
|
859
|
+
def grantTypes(self):
|
|
860
|
+
return self.grant_types
|
|
861
|
+
|
|
862
|
+
@property
|
|
863
|
+
def responseTypes(self):
|
|
864
|
+
return self.response_types
|
|
865
|
+
|
|
866
|
+
@property
|
|
867
|
+
def tokenEndpointAuthMethod(self):
|
|
868
|
+
return self.token_endpoint_auth_method
|
|
869
|
+
|
|
870
|
+
@property
|
|
871
|
+
def authorizationUrl(self):
|
|
872
|
+
return self.authorization_url
|
|
873
|
+
|
|
874
|
+
@property
|
|
875
|
+
def tokenUrl(self):
|
|
876
|
+
return self.token_url
|
|
877
|
+
|
|
878
|
+
@property
|
|
879
|
+
def revocationUrl(self):
|
|
880
|
+
return self.revocation_url
|
|
881
|
+
|
|
882
|
+
@property
|
|
883
|
+
def userinfoUrl(self):
|
|
884
|
+
return self.userinfo_url
|
|
885
|
+
|
|
886
|
+
@property
|
|
887
|
+
def codeChallengeMethodsSupported(self):
|
|
888
|
+
return self.code_challenge_methods_supported
|
|
889
|
+
|
|
890
|
+
@property
|
|
891
|
+
def clientSecret(self):
|
|
892
|
+
return self.client_secret
|
|
893
|
+
|
|
894
|
+
@property
|
|
895
|
+
def clientIdIssuedAt(self):
|
|
896
|
+
return self.client_id_issued_at
|
|
897
|
+
|
|
898
|
+
@property
|
|
899
|
+
def clientSecretExpiresAt(self):
|
|
900
|
+
return self.client_secret_expires_at
|
|
901
|
+
|
|
902
|
+
|
|
903
|
+
class StartOAuthFlowRequest(KaggleObject):
|
|
904
|
+
r"""
|
|
905
|
+
Attributes:
|
|
906
|
+
client_id (str)
|
|
907
|
+
Client id that is initiating this OAuth flow.
|
|
908
|
+
redirect_uri (str)
|
|
909
|
+
Url to redirect the user after the OAuth flow is complete. For example, if
|
|
910
|
+
you specify https://dataverse.org/auth/kaggle, you will receive a request
|
|
911
|
+
like
|
|
912
|
+
https://dataverse.org/auth/kaggle?code=808f9afcabb3489a8b30353a8ae4dc4b.
|
|
913
|
+
Note that this url must match the allowed urls defined for your OAuth
|
|
914
|
+
client. Also it must be a loopback url for public clients.
|
|
915
|
+
scope (str)
|
|
916
|
+
Set of authorization scopes to restrict the generated tokens. Must be
|
|
917
|
+
specified.
|
|
918
|
+
state (str)
|
|
919
|
+
Random string to protect against CSRF attacks.
|
|
920
|
+
code_challenge (str)
|
|
921
|
+
Hash of the random 'code_verifier' string generated by the caller. The
|
|
922
|
+
client will later send the 'code_verifier' to the backend, which will
|
|
923
|
+
verify its hash against this value (see the 'api/v1/oauth2/exchange'
|
|
924
|
+
(ExchangeOAuthTokenRequest) endpoint). Required for public clients.
|
|
925
|
+
code_challenge_method (str)
|
|
926
|
+
Code challenge method used to hash the 'code_challenge' above. Must be set
|
|
927
|
+
to 'S256', which means the SHA-256 hash of the 'code_verifier', Base64URL
|
|
928
|
+
encoded. Required for public clients.
|
|
929
|
+
response_type (str)
|
|
930
|
+
Type of the OAuth flow completed response. Must be set to 'code', which
|
|
931
|
+
means OAuth code will be sent instead of a refresh token.
|
|
932
|
+
response_mode (str)
|
|
933
|
+
Mode of the OAuth flow completed response. Must be set to 'query', which
|
|
934
|
+
means response will be sent as query string parameters.
|
|
935
|
+
resource (str)
|
|
936
|
+
The 'resource' parameter is not part of the OAuth2 spec, but is sent by
|
|
937
|
+
some clients. We are capturing it here to avoid 'invalid field' errors.
|
|
938
|
+
"""
|
|
939
|
+
|
|
940
|
+
def __init__(self):
|
|
941
|
+
self._client_id = ""
|
|
942
|
+
self._redirect_uri = ""
|
|
943
|
+
self._scope = ""
|
|
944
|
+
self._state = ""
|
|
945
|
+
self._code_challenge = None
|
|
946
|
+
self._code_challenge_method = None
|
|
947
|
+
self._response_type = ""
|
|
948
|
+
self._response_mode = ""
|
|
949
|
+
self._resource = None
|
|
950
|
+
self._freeze()
|
|
951
|
+
|
|
952
|
+
@property
|
|
953
|
+
def client_id(self) -> str:
|
|
954
|
+
"""Client id that is initiating this OAuth flow."""
|
|
955
|
+
return self._client_id
|
|
956
|
+
|
|
957
|
+
@client_id.setter
|
|
958
|
+
def client_id(self, client_id: str):
|
|
959
|
+
if client_id is None:
|
|
960
|
+
del self.client_id
|
|
961
|
+
return
|
|
962
|
+
if not isinstance(client_id, str):
|
|
963
|
+
raise TypeError('client_id must be of type str')
|
|
964
|
+
self._client_id = client_id
|
|
965
|
+
|
|
966
|
+
@property
|
|
967
|
+
def redirect_uri(self) -> str:
|
|
968
|
+
r"""
|
|
969
|
+
Url to redirect the user after the OAuth flow is complete. For example, if
|
|
970
|
+
you specify https://dataverse.org/auth/kaggle, you will receive a request
|
|
971
|
+
like
|
|
972
|
+
https://dataverse.org/auth/kaggle?code=808f9afcabb3489a8b30353a8ae4dc4b.
|
|
973
|
+
Note that this url must match the allowed urls defined for your OAuth
|
|
974
|
+
client. Also it must be a loopback url for public clients.
|
|
975
|
+
"""
|
|
976
|
+
return self._redirect_uri
|
|
977
|
+
|
|
978
|
+
@redirect_uri.setter
|
|
979
|
+
def redirect_uri(self, redirect_uri: str):
|
|
980
|
+
if redirect_uri is None:
|
|
981
|
+
del self.redirect_uri
|
|
982
|
+
return
|
|
983
|
+
if not isinstance(redirect_uri, str):
|
|
984
|
+
raise TypeError('redirect_uri must be of type str')
|
|
985
|
+
self._redirect_uri = redirect_uri
|
|
986
|
+
|
|
987
|
+
@property
|
|
988
|
+
def scope(self) -> str:
|
|
989
|
+
r"""
|
|
990
|
+
Set of authorization scopes to restrict the generated tokens. Must be
|
|
991
|
+
specified.
|
|
992
|
+
"""
|
|
993
|
+
return self._scope
|
|
994
|
+
|
|
995
|
+
@scope.setter
|
|
996
|
+
def scope(self, scope: str):
|
|
997
|
+
if scope is None:
|
|
998
|
+
del self.scope
|
|
999
|
+
return
|
|
1000
|
+
if not isinstance(scope, str):
|
|
1001
|
+
raise TypeError('scope must be of type str')
|
|
1002
|
+
self._scope = scope
|
|
1003
|
+
|
|
1004
|
+
@property
|
|
1005
|
+
def state(self) -> str:
|
|
1006
|
+
"""Random string to protect against CSRF attacks."""
|
|
1007
|
+
return self._state
|
|
1008
|
+
|
|
1009
|
+
@state.setter
|
|
1010
|
+
def state(self, state: str):
|
|
1011
|
+
if state is None:
|
|
1012
|
+
del self.state
|
|
1013
|
+
return
|
|
1014
|
+
if not isinstance(state, str):
|
|
1015
|
+
raise TypeError('state must be of type str')
|
|
1016
|
+
self._state = state
|
|
1017
|
+
|
|
1018
|
+
@property
|
|
1019
|
+
def code_challenge(self) -> str:
|
|
1020
|
+
r"""
|
|
1021
|
+
Hash of the random 'code_verifier' string generated by the caller. The
|
|
1022
|
+
client will later send the 'code_verifier' to the backend, which will
|
|
1023
|
+
verify its hash against this value (see the 'api/v1/oauth2/exchange'
|
|
1024
|
+
(ExchangeOAuthTokenRequest) endpoint). Required for public clients.
|
|
1025
|
+
"""
|
|
1026
|
+
return self._code_challenge or ""
|
|
1027
|
+
|
|
1028
|
+
@code_challenge.setter
|
|
1029
|
+
def code_challenge(self, code_challenge: Optional[str]):
|
|
1030
|
+
if code_challenge is None:
|
|
1031
|
+
del self.code_challenge
|
|
1032
|
+
return
|
|
1033
|
+
if not isinstance(code_challenge, str):
|
|
1034
|
+
raise TypeError('code_challenge must be of type str')
|
|
1035
|
+
self._code_challenge = code_challenge
|
|
1036
|
+
|
|
1037
|
+
@property
|
|
1038
|
+
def code_challenge_method(self) -> str:
|
|
1039
|
+
r"""
|
|
1040
|
+
Code challenge method used to hash the 'code_challenge' above. Must be set
|
|
1041
|
+
to 'S256', which means the SHA-256 hash of the 'code_verifier', Base64URL
|
|
1042
|
+
encoded. Required for public clients.
|
|
1043
|
+
"""
|
|
1044
|
+
return self._code_challenge_method or ""
|
|
1045
|
+
|
|
1046
|
+
@code_challenge_method.setter
|
|
1047
|
+
def code_challenge_method(self, code_challenge_method: Optional[str]):
|
|
1048
|
+
if code_challenge_method is None:
|
|
1049
|
+
del self.code_challenge_method
|
|
1050
|
+
return
|
|
1051
|
+
if not isinstance(code_challenge_method, str):
|
|
1052
|
+
raise TypeError('code_challenge_method must be of type str')
|
|
1053
|
+
self._code_challenge_method = code_challenge_method
|
|
1054
|
+
|
|
1055
|
+
@property
|
|
1056
|
+
def response_type(self) -> str:
|
|
1057
|
+
r"""
|
|
1058
|
+
Type of the OAuth flow completed response. Must be set to 'code', which
|
|
1059
|
+
means OAuth code will be sent instead of a refresh token.
|
|
1060
|
+
"""
|
|
1061
|
+
return self._response_type
|
|
1062
|
+
|
|
1063
|
+
@response_type.setter
|
|
1064
|
+
def response_type(self, response_type: str):
|
|
1065
|
+
if response_type is None:
|
|
1066
|
+
del self.response_type
|
|
1067
|
+
return
|
|
1068
|
+
if not isinstance(response_type, str):
|
|
1069
|
+
raise TypeError('response_type must be of type str')
|
|
1070
|
+
self._response_type = response_type
|
|
1071
|
+
|
|
1072
|
+
@property
|
|
1073
|
+
def response_mode(self) -> str:
|
|
1074
|
+
r"""
|
|
1075
|
+
Mode of the OAuth flow completed response. Must be set to 'query', which
|
|
1076
|
+
means response will be sent as query string parameters.
|
|
1077
|
+
"""
|
|
1078
|
+
return self._response_mode
|
|
1079
|
+
|
|
1080
|
+
@response_mode.setter
|
|
1081
|
+
def response_mode(self, response_mode: str):
|
|
1082
|
+
if response_mode is None:
|
|
1083
|
+
del self.response_mode
|
|
1084
|
+
return
|
|
1085
|
+
if not isinstance(response_mode, str):
|
|
1086
|
+
raise TypeError('response_mode must be of type str')
|
|
1087
|
+
self._response_mode = response_mode
|
|
1088
|
+
|
|
1089
|
+
@property
|
|
1090
|
+
def resource(self) -> str:
|
|
1091
|
+
r"""
|
|
1092
|
+
The 'resource' parameter is not part of the OAuth2 spec, but is sent by
|
|
1093
|
+
some clients. We are capturing it here to avoid 'invalid field' errors.
|
|
1094
|
+
"""
|
|
1095
|
+
return self._resource or ""
|
|
1096
|
+
|
|
1097
|
+
@resource.setter
|
|
1098
|
+
def resource(self, resource: Optional[str]):
|
|
1099
|
+
if resource is None:
|
|
1100
|
+
del self.resource
|
|
1101
|
+
return
|
|
1102
|
+
if not isinstance(resource, str):
|
|
1103
|
+
raise TypeError('resource must be of type str')
|
|
1104
|
+
self._resource = resource
|
|
1105
|
+
|
|
1106
|
+
def endpoint(self):
|
|
1107
|
+
path = '/api/v1/oauth2/authorize'
|
|
1108
|
+
return path.format_map(self.to_field_map(self))
|
|
1109
|
+
|
|
1110
|
+
|
|
1111
|
+
ExchangeOAuthTokenRequest._fields = [
|
|
1112
|
+
FieldMetadata("code", "code", "_code", str, None, PredefinedSerializer(), optional=True),
|
|
1113
|
+
FieldMetadata("codeVerifier", "code_verifier", "_code_verifier", str, None, PredefinedSerializer(), optional=True),
|
|
1114
|
+
FieldMetadata("grantType", "grant_type", "_grant_type", str, "", PredefinedSerializer()),
|
|
1115
|
+
FieldMetadata("clientId", "client_id", "_client_id", str, None, PredefinedSerializer(), optional=True),
|
|
1116
|
+
FieldMetadata("redirectUri", "redirect_uri", "_redirect_uri", str, None, PredefinedSerializer(), optional=True),
|
|
1117
|
+
FieldMetadata("resource", "resource", "_resource", str, None, PredefinedSerializer(), optional=True),
|
|
1118
|
+
FieldMetadata("refreshToken", "refresh_token", "_refresh_token", str, None, PredefinedSerializer(), optional=True),
|
|
1119
|
+
]
|
|
1120
|
+
|
|
1121
|
+
ExchangeOAuthTokenResponse._fields = [
|
|
1122
|
+
FieldMetadata("accessToken", "access_token", "_access_token", str, "", PredefinedSerializer()),
|
|
1123
|
+
FieldMetadata("refreshToken", "refresh_token", "_refresh_token", str, "", PredefinedSerializer()),
|
|
1124
|
+
FieldMetadata("tokenType", "token_type", "_token_type", str, "", PredefinedSerializer()),
|
|
1125
|
+
FieldMetadata("expiresIn", "expires_in", "_expires_in", int, 0, PredefinedSerializer()),
|
|
1126
|
+
FieldMetadata("username", "username", "_username", str, "", PredefinedSerializer()),
|
|
1127
|
+
FieldMetadata("userId", "user_id", "_user_id", int, 0, PredefinedSerializer()),
|
|
1128
|
+
FieldMetadata("scope", "scope", "_scope", str, None, PredefinedSerializer(), optional=True),
|
|
1129
|
+
]
|
|
1130
|
+
|
|
1131
|
+
IntrospectTokenRequest._fields = [
|
|
1132
|
+
FieldMetadata("token", "token", "_token", str, "", PredefinedSerializer()),
|
|
1133
|
+
]
|
|
1134
|
+
|
|
1135
|
+
IntrospectTokenResponse._fields = [
|
|
1136
|
+
FieldMetadata("active", "active", "_active", bool, False, PredefinedSerializer()),
|
|
1137
|
+
FieldMetadata("clientId", "client_id", "_client_id", str, "", PredefinedSerializer()),
|
|
1138
|
+
FieldMetadata("username", "username", "_username", str, "", PredefinedSerializer()),
|
|
1139
|
+
FieldMetadata("userId", "user_id", "_user_id", int, None, PredefinedSerializer(), optional=True),
|
|
1140
|
+
FieldMetadata("scope", "scope", "_scope", str, "", PredefinedSerializer()),
|
|
1141
|
+
FieldMetadata("exp", "exp", "_exp", int, None, PredefinedSerializer(), optional=True),
|
|
1142
|
+
]
|
|
1143
|
+
|
|
1144
|
+
RegisterOAuthClientRequest._fields = [
|
|
1145
|
+
FieldMetadata("clientName", "client_name", "_client_name", str, "", PredefinedSerializer()),
|
|
1146
|
+
FieldMetadata("redirectUris", "redirect_uris", "_redirect_uris", str, [], ListSerializer(PredefinedSerializer())),
|
|
1147
|
+
FieldMetadata("grantTypes", "grant_types", "_grant_types", str, [], ListSerializer(PredefinedSerializer())),
|
|
1148
|
+
FieldMetadata("tokenEndpointAuthMethod", "token_endpoint_auth_method", "_token_endpoint_auth_method", str, "", PredefinedSerializer()),
|
|
1149
|
+
FieldMetadata("scope", "scope", "_scope", str, None, PredefinedSerializer(), optional=True),
|
|
1150
|
+
FieldMetadata("codeChallengeMethod", "code_challenge_method", "_code_challenge_method", str, [], ListSerializer(PredefinedSerializer())),
|
|
1151
|
+
]
|
|
1152
|
+
|
|
1153
|
+
RegisterOAuthClientResponse._fields = [
|
|
1154
|
+
FieldMetadata("client_id", "client_id", "_client_id", str, "", PredefinedSerializer()),
|
|
1155
|
+
FieldMetadata("redirect_uris", "redirect_uris", "_redirect_uris", str, [], ListSerializer(PredefinedSerializer())),
|
|
1156
|
+
FieldMetadata("grant_types", "grant_types", "_grant_types", str, [], ListSerializer(PredefinedSerializer())),
|
|
1157
|
+
FieldMetadata("response_types", "response_types", "_response_types", str, [], ListSerializer(PredefinedSerializer())),
|
|
1158
|
+
FieldMetadata("token_endpoint_auth_method", "token_endpoint_auth_method", "_token_endpoint_auth_method", str, "", PredefinedSerializer()),
|
|
1159
|
+
FieldMetadata("scope", "scope", "_scope", str, None, PredefinedSerializer(), optional=True),
|
|
1160
|
+
FieldMetadata("authorization_url", "authorization_url", "_authorization_url", str, None, PredefinedSerializer(), optional=True),
|
|
1161
|
+
FieldMetadata("token_url", "token_url", "_token_url", str, None, PredefinedSerializer(), optional=True),
|
|
1162
|
+
FieldMetadata("client_secret", "client_secret", "_client_secret", str, None, PredefinedSerializer(), optional=True),
|
|
1163
|
+
FieldMetadata("client_id_issued_at", "client_id_issued_at", "_client_id_issued_at", int, None, PredefinedSerializer(), optional=True),
|
|
1164
|
+
FieldMetadata("client_secret_expires_at", "client_secret_expires_at", "_client_secret_expires_at", int, None, PredefinedSerializer(), optional=True),
|
|
1165
|
+
FieldMetadata("revocation_url", "revocation_url", "_revocation_url", str, None, PredefinedSerializer(), optional=True),
|
|
1166
|
+
FieldMetadata("userinfo_url", "userinfo_url", "_userinfo_url", str, None, PredefinedSerializer(), optional=True),
|
|
1167
|
+
FieldMetadata("code_challenge_methods_supported", "code_challenge_methods_supported", "_code_challenge_methods_supported", str, [], ListSerializer(PredefinedSerializer())),
|
|
1168
|
+
]
|
|
1169
|
+
|
|
1170
|
+
StartOAuthFlowRequest._fields = [
|
|
1171
|
+
FieldMetadata("clientId", "client_id", "_client_id", str, "", PredefinedSerializer()),
|
|
1172
|
+
FieldMetadata("redirectUri", "redirect_uri", "_redirect_uri", str, "", PredefinedSerializer()),
|
|
1173
|
+
FieldMetadata("scope", "scope", "_scope", str, "", PredefinedSerializer()),
|
|
1174
|
+
FieldMetadata("state", "state", "_state", str, "", PredefinedSerializer()),
|
|
1175
|
+
FieldMetadata("codeChallenge", "code_challenge", "_code_challenge", str, None, PredefinedSerializer(), optional=True),
|
|
1176
|
+
FieldMetadata("codeChallengeMethod", "code_challenge_method", "_code_challenge_method", str, None, PredefinedSerializer(), optional=True),
|
|
1177
|
+
FieldMetadata("responseType", "response_type", "_response_type", str, "", PredefinedSerializer()),
|
|
1178
|
+
FieldMetadata("responseMode", "response_mode", "_response_mode", str, "", PredefinedSerializer()),
|
|
1179
|
+
FieldMetadata("resource", "resource", "_resource", str, None, PredefinedSerializer(), optional=True),
|
|
1180
|
+
]
|
|
1181
|
+
|