//native
/**
* Get Current User
* Returns the profile of the user that the API token authenticates as (account ID, display name, email).
*/
export async function main(auth: RT.Confluence) {
const base = auth.baseUrl.replace(/\/$/, "")
const url = new URL(`${base}/wiki/rest/api/user/current`)
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Basic " + btoa(`${auth.email}:${auth.apiToken}`),
Accept: "application/json",
},
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 4 hours ago