MCPcopy Create free account
hub / github.com/su-kaka/gcli2api / _prepare_credentials_data

Function _prepare_credentials_data

src/auth.py:45–75  ·  view source on GitHub ↗

准备凭证数据字典(统一函数)

(credentials: Credentials, project_id: str, mode: str = "geminicli", subscription_tier: str = None)

Source from the content-addressed store, hash-verified

43
44
45def _prepare_credentials_data(credentials: Credentials, project_id: str, mode: str = "geminicli", subscription_tier: str = None) -> Dict[str, Any]:
46 """准备凭证数据字典(统一函数)"""
47 if mode == "antigravity":
48 creds_data = {
49 "client_id": ANTIGRAVITY_CLIENT_ID,
50 "client_secret": ANTIGRAVITY_CLIENT_SECRET,
51 "token": credentials.access_token,
52 "refresh_token": credentials.refresh_token,
53 "scopes": ANTIGRAVITY_SCOPES,
54 "token_uri": TOKEN_URL,
55 "project_id": project_id,
56 }
57 else:
58 creds_data = {
59 "client_id": CLIENT_ID,
60 "client_secret": CLIENT_SECRET,
61 "token": credentials.access_token,
62 "refresh_token": credentials.refresh_token,
63 "scopes": SCOPES,
64 "token_uri": TOKEN_URL,
65 "project_id": project_id,
66 }
67
68 if credentials.expires_at:
69 if credentials.expires_at.tzinfo is None:
70 expiry_utc = credentials.expires_at.replace(tzinfo=timezone.utc)
71 else:
72 expiry_utc = credentials.expires_at
73 creds_data["expiry"] = expiry_utc.isoformat()
74
75 return creds_data
76
77
78def _cleanup_auth_flow_server(state: str):

Callers 4

complete_auth_flowFunction · 0.85
save_credentialsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected