//native
/**
* Get Current User
* Get the account the credentials belong to: account ID, display name, email, time zone. A quick way to check the resource works.
*/
export async function main(auth: RT.Jira, expand: string | undefined) {
const url = new URL(`https://${auth.domain}.atlassian.net/rest/api/3/myself`)
if (expand != null && expand !== "") {
url.searchParams.append("expand", expand)
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: `Basic ${btoa(`${auth.username}:${auth.password}`)}`,
Accept: "application/json",
},
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 8 days ago