작업계획서대로 진행

This commit is contained in:
2026-01-11 22:45:23 +09:00
parent da4d22e9c1
commit 4f6fe212e2
3 changed files with 24 additions and 9 deletions

View File

@@ -26,16 +26,20 @@ export default defineEventHandler(async (event) => {
try {
// 1. 코드로 액세스 토큰 교환
const tokenParams = new URLSearchParams({
grant_type: 'authorization_code',
code: code,
client_id: config.synologyClientId,
redirect_uri: config.synologyRedirectUri
})
if (config.synologyClientSecret) {
tokenParams.set('client_secret', config.synologyClientSecret)
}
const tokenResponse = await $fetch<any>(`${config.synologyServerUrl}/webman/sso/SSOAccessToken.cgi`, {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams({
grant_type: 'authorization_code',
code: code,
client_id: config.synologyClientId,
client_secret: config.synologyClientSecret,
redirect_uri: config.synologyRedirectUri
}).toString()
body: tokenParams.toString()
})
if (!tokenResponse.access_token) {