//native
type Fly = {
token: string;
};
/**
* Request an OIDC token
* Request an Open ID Connect token for your machine. Customize the audience claim with the `aud` parameter. This returns a JWT token. Learn more about using OpenID Connect on Fly.io.
*/
export async function main(
auth: Fly,
body: { aud?: string; aws_principal_tags?: false | true },
) {
const url = new URL(`https://api.machines.dev/v1/tokens/oidc`);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago