1
0
elk/server/api/[server]/oauth.ts
2022-11-15 19:54:07 +08:00

22 lines
591 B
TypeScript

import { getQuery } from 'ufo'
export default defineEventHandler(async (event) => {
const query = getQuery(event.req.url!)
const code = query.code
const server = event.context.params.server
console.log({ query, server })
const res = await $fetch(`https://${server}/oauth/token`, {
method: 'POST',
body: {
client_id: 'your_client_id_here',
client_secret: 'your_client_secret_here',
redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',
grant_type: 'authorization_code',
code,
scope: 'read write follow push',
},
})
console.log({ res })
})