Swagger API 文檔
完整的 API 規格、參數說明,可直接測試 API
登入 MCC Manager,建立群組和服務,取得整合所需的參數。
service_suuid、GROUP_JWT、SERVICE_CODEredirect_uri 加入白名單(需完全匹配)
在 MCC Manager 中啟用並設定 Google / LINE / Facebook 登入。
https://members.managers.center/auth/idp/{provider}/callbackgoogle、line、facebook
前端導向 MCC 啟動登入,處理回調取得 code,再由後端兌換憑證。
GET /auth/idp/{provider}/startresponse_mode=code(安全性最高)
| 參數 | 說明 | 使用位置 |
|---|---|---|
service_suuid |
服務識別碼 | 前端 |
redirect_uri |
登入完成後的回調網址 | 前端 |
GROUP_JWT |
群組 Bearer Token | 後端 |
SERVICE_CODE |
服務代碼(X-Service-Code) | 後端 |
⚠️ GROUP_JWT 和 SERVICE_CODE 是敏感資訊,務必存放在後端環境變數中!
const MCC_BASE = 'https://members.managers.center';
const SERVICE_SUUID = 'your-service-suuid';
const REDIRECT_URI = 'https://your-site.com/callback';
function loginWith(provider) {
const params = new URLSearchParams({
service_suuid: SERVICE_SUUID,
redirect_uri: REDIRECT_URI,
response_mode: 'code'
});
window.location.href =
`${MCC_BASE}/auth/idp/${provider}/start?${params}`;
}
// callback.html
const params = new URLSearchParams(location.search);
const code = params.get('code');
if (code) {
// 將 code 送給後端兌換
fetch('/api/auth/exchange', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ code })
}).then(r => r.json())
.then(data => {
if (data.success) {
localStorage.setItem('member_suuid', data.data.member_suuid);
localStorage.setItem('access_token', data.data.accessToken);
}
});
}
const MCC_BASE = 'https://members.managers.center';
const GROUP_JWT = process.env.GROUP_JWT; // 從環境變數取得
const SERVICE_CODE = process.env.SERVICE_CODE;
app.post('/api/auth/exchange', async (req, res) => {
const { code } = req.body;
const response = await fetch(`${MCC_BASE}/auth/idp/exchange`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${GROUP_JWT}`,
'X-Service-Code': SERVICE_CODE,
'Content-Type': 'application/json'
},
body: JSON.stringify({ code })
});
const data = await response.json();
res.json(data); // { success: true, data: { member_suuid, accessToken } }
});
// 驗證會員 accessToken 是否有效
app.post('/api/member/check', async (req, res) => {
const { member_suuid, access_token } = req.body;
const response = await fetch(`${MCC_BASE}/member/check`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${GROUP_JWT}`,
'X-Service-Code': SERVICE_CODE,
'X-Member-Suuid': member_suuid,
'X-Member-Access-Token': access_token,
'Content-Type': 'application/json'
}
});
const data = await response.json();
// { success: true, data: { member_suuid, email, display_name, ttl, ... } }
res.json(data);
});
GROUP_JWT 和 SERVICE_CODE 只能存放在後端環境變數,切勿暴露給前端
response_mode=code,避免 token 暴露在 URL 中