pixelarraythirdparty 1.1.3__py3-none-any.whl → 1.1.4__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.
- pixelarraythirdparty/__init__.py +1 -1
- pixelarraythirdparty/unified_login/unified_login.py +83 -0
- {pixelarraythirdparty-1.1.3.dist-info → pixelarraythirdparty-1.1.4.dist-info}/METADATA +1 -1
- {pixelarraythirdparty-1.1.3.dist-info → pixelarraythirdparty-1.1.4.dist-info}/RECORD +7 -7
- {pixelarraythirdparty-1.1.3.dist-info → pixelarraythirdparty-1.1.4.dist-info}/WHEEL +0 -0
- {pixelarraythirdparty-1.1.3.dist-info → pixelarraythirdparty-1.1.4.dist-info}/licenses/LICENSE +0 -0
- {pixelarraythirdparty-1.1.3.dist-info → pixelarraythirdparty-1.1.4.dist-info}/top_level.txt +0 -0
pixelarraythirdparty/__init__.py
CHANGED
|
@@ -376,3 +376,86 @@ class DouyinLogin(AsyncClient):
|
|
|
376
376
|
await asyncio.sleep(interval)
|
|
377
377
|
|
|
378
378
|
return {}, False
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
class GitLabLogin(AsyncClient):
|
|
382
|
+
"""
|
|
383
|
+
GitLab OAuth2 登录客户端
|
|
384
|
+
|
|
385
|
+
使用示例:
|
|
386
|
+
```
|
|
387
|
+
gitlab = GitLabLogin(api_key="your_api_key")
|
|
388
|
+
user_info, success = await gitlab.login()
|
|
389
|
+
```
|
|
390
|
+
"""
|
|
391
|
+
|
|
392
|
+
def __init__(self, api_key: str):
|
|
393
|
+
super().__init__(api_key)
|
|
394
|
+
|
|
395
|
+
async def _get_auth_url(self) -> Tuple[Optional[Dict[str, str]], bool]:
|
|
396
|
+
data, success = await self._request(
|
|
397
|
+
"POST", "/api/unified-login/gitlab/auth-url"
|
|
398
|
+
)
|
|
399
|
+
if not success:
|
|
400
|
+
return None, False
|
|
401
|
+
auth_url = data.get("auth_url")
|
|
402
|
+
if not auth_url:
|
|
403
|
+
return None, False
|
|
404
|
+
return data, True
|
|
405
|
+
|
|
406
|
+
async def login(self, timeout: int = 180) -> Tuple[Dict, bool]:
|
|
407
|
+
"""
|
|
408
|
+
仿 Supabase CLI 的一键登录流程:打开浏览器完成授权,
|
|
409
|
+
终端端轮询等待登录结果
|
|
410
|
+
|
|
411
|
+
:param timeout: 等待用户完成授权的超时时间(秒)
|
|
412
|
+
"""
|
|
413
|
+
auth_data, success = await self._get_auth_url()
|
|
414
|
+
if not success or not auth_data:
|
|
415
|
+
return {}, False
|
|
416
|
+
|
|
417
|
+
auth_url = auth_data.get("auth_url")
|
|
418
|
+
state = auth_data.get("state") or self._extract_state(auth_url)
|
|
419
|
+
|
|
420
|
+
if not auth_url or not state:
|
|
421
|
+
return {}, False
|
|
422
|
+
|
|
423
|
+
webbrowser.open(auth_url, new=2)
|
|
424
|
+
|
|
425
|
+
return await self._wait_for_gitlab_login(state, timeout)
|
|
426
|
+
|
|
427
|
+
def _extract_state(self, auth_url: Optional[str]) -> Optional[str]:
|
|
428
|
+
if not auth_url:
|
|
429
|
+
return None
|
|
430
|
+
try:
|
|
431
|
+
parsed = urllib.parse.urlparse(auth_url)
|
|
432
|
+
query = urllib.parse.parse_qs(parsed.query)
|
|
433
|
+
values = query.get("state")
|
|
434
|
+
if values:
|
|
435
|
+
return values[0]
|
|
436
|
+
except Exception:
|
|
437
|
+
return None
|
|
438
|
+
return None
|
|
439
|
+
|
|
440
|
+
async def _wait_for_gitlab_login(
|
|
441
|
+
self, state: str, timeout: int
|
|
442
|
+
) -> Tuple[Dict, bool]:
|
|
443
|
+
interval = 2
|
|
444
|
+
total_checks = max(1, timeout // interval) if timeout > 0 else 1
|
|
445
|
+
|
|
446
|
+
for _ in range(total_checks):
|
|
447
|
+
status, response = await self._request_raw(
|
|
448
|
+
"POST",
|
|
449
|
+
"/api/unified-login/gitlab/wait-login",
|
|
450
|
+
json={"state": state},
|
|
451
|
+
)
|
|
452
|
+
|
|
453
|
+
if status == 200 and response.get("success") is True:
|
|
454
|
+
return response.get("data", {}), True
|
|
455
|
+
|
|
456
|
+
if status in (400, 408):
|
|
457
|
+
break
|
|
458
|
+
|
|
459
|
+
await asyncio.sleep(interval)
|
|
460
|
+
|
|
461
|
+
return {}, False
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
pixelarraythirdparty/__init__.py,sha256=
|
|
1
|
+
pixelarraythirdparty/__init__.py,sha256=qAVaFfm351627tHGTInpG4j-pNCHsla0pkdyNBTzbdo,490
|
|
2
2
|
pixelarraythirdparty/client.py,sha256=DY8w2DYsoGQ6cZYqT-FfoovmVd3Ry-aJbJls2Cxat8M,2006
|
|
3
3
|
pixelarraythirdparty/cron/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
pixelarraythirdparty/cron/cron.py,sha256=2oxnIJvRY0A-ynhKSHJvZmJLj1EWzYcqSIl8r9yh9a0,4402
|
|
@@ -7,11 +7,11 @@ pixelarraythirdparty/order/order.py,sha256=rk9O73m5kOhjzavq3wIfN-JKj3cLwAItHVTJ2
|
|
|
7
7
|
pixelarraythirdparty/product/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
8
|
pixelarraythirdparty/product/product.py,sha256=5fgv2Ck860epYXxipY83vePziubCIlocFu43mGt_bhM,7497
|
|
9
9
|
pixelarraythirdparty/unified_login/__init__.py,sha256=2ejSpO0gp-J-XkT5p19V45FlYOW7-NO_aCExukfUTIo,123
|
|
10
|
-
pixelarraythirdparty/unified_login/unified_login.py,sha256=
|
|
10
|
+
pixelarraythirdparty/unified_login/unified_login.py,sha256=bbbUvYlcR_G5zdfXaDHRZkg9gGjKniVD6cUaKOxhfPQ,14134
|
|
11
11
|
pixelarraythirdparty/user/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
12
|
pixelarraythirdparty/user/user.py,sha256=v018iisB5AQNs7AtrHIGfu8YIorX0vflDClsKrt3ZMU,5898
|
|
13
|
-
pixelarraythirdparty-1.1.
|
|
14
|
-
pixelarraythirdparty-1.1.
|
|
15
|
-
pixelarraythirdparty-1.1.
|
|
16
|
-
pixelarraythirdparty-1.1.
|
|
17
|
-
pixelarraythirdparty-1.1.
|
|
13
|
+
pixelarraythirdparty-1.1.4.dist-info/licenses/LICENSE,sha256=O-g1dUr0U50rSIvmWE9toiVkSgFpVt72_MHITbWvAqA,1067
|
|
14
|
+
pixelarraythirdparty-1.1.4.dist-info/METADATA,sha256=aAkOq2yeMF1AwgwenBanQoOY1iEGh9paSa6uj9ULD6s,993
|
|
15
|
+
pixelarraythirdparty-1.1.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
16
|
+
pixelarraythirdparty-1.1.4.dist-info/top_level.txt,sha256=dzG2Ut8j7noUqj_0ZQjcIDAeHYCh_9WtlxjAxtoyufo,21
|
|
17
|
+
pixelarraythirdparty-1.1.4.dist-info/RECORD,,
|
|
File without changes
|
{pixelarraythirdparty-1.1.3.dist-info → pixelarraythirdparty-1.1.4.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|