fix: only use oauth redirects and add website to app registration details

This commit is contained in:
Daniel Roe 2022-11-29 22:55:53 +00:00
parent 98a647f8ca
commit 81732a4a8c
No known key found for this signature in database
GPG key ID: 22D5008E4F5D9B55
3 changed files with 27 additions and 19 deletions

View file

@ -7,7 +7,6 @@ import { parseURL } from 'ufo'
import { $fetch } from 'ohmyfetch'
import type { Storage } from 'unstorage'
import { isCI } from 'std-env'
import cached from './cache-driver'
import type { AppInfo } from '~/types'
@ -32,18 +31,17 @@ else {
apiToken: config.cloudflare.apiToken,
})))
}
export function getRedirectURI(server: string) {
return `${HOST_URL}/api/${server}/oauth`
}
async function fetchAppInfo(server: string) {
const redirect_uris = [
'urn:ietf:wg:oauth:2.0:oob',
`${HOST_URL}/api/${server}/oauth`,
].join('\n')
const app: AppInfo = await $fetch(`https://${server}/api/v1/apps`, {
method: 'POST',
body: {
client_name: APP_NAME + (isCI ? '' : ' (dev)'),
redirect_uris,
client_name: APP_NAME + (config.env === 'local' ? ' (dev)' : ''),
website: 'https://elk.zone',
redirect_uris: getRedirectURI(server),
scopes: 'read write follow push',
},
})