export type GetApiOauth2ApplicationsMeOptions = {baseUrl: string, apikeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * get own oauth2 application * * GET /oauth2/applications/@me */ export const getApiOauth2ApplicationsMe = async (options: GetApiOauth2ApplicationsMeOptions) => { const {baseUrl, fetch: fetchFn = fetch, apikeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/plain") if (apikeyAuth !== undefined) headers.set('authorization', `apikey ${apikeyAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/oauth2/applications/@me${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.text() };