MCPcopy Create free account
hub / github.com/smallfawn/QLScriptPublic / loginByCode

Function loginByCode

wxapp/aima.js:152–168  ·  view source on GitHub ↗
(account)

Source from the content-addressed store, hash-verified

150}
151
152async function loginByCode(account) {
153 $.log("🔐 正在获取code并登录...");
154 const code = await getWxCode(account);
155 const res = await request("post", `${WXCLIENT_URL}/user/members:login`, "", {
156 data: { code },
157 account,
158 });
159
160 const token = getResponseToken(res.headers);
161 if (res.status !== 200 || res.data?.code !== 200 || !token) {
162 throw new Error(`登录失败: HTTP ${res.status} ${JSON.stringify(res.data)}`);
163 }
164
165 updateCachedToken(account, token);
166 $.log(`✅ 登录成功,已缓存token: ${maskToken(token)}`);
167 return token;
168}
169
170async function validateToken(account, token) {
171 const res = await request("get", `${WXCLIENT_URL}/member/IndexInfo`, token, {

Callers 1

getAccessTokenFunction · 0.70

Calls 6

getResponseTokenFunction · 0.85
updateCachedTokenFunction · 0.85
getWxCodeFunction · 0.70
requestFunction · 0.70
maskTokenFunction · 0.70
logMethod · 0.45

Tested by

no test coverage detected