chore: wip oauth

This commit is contained in:
Anthony Fu 2022-11-15 19:54:07 +08:00
parent 6755ed6f94
commit 6ea4879190
8 changed files with 75 additions and 10 deletions

View file

@ -0,0 +1,21 @@
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 })
})