//native
type Persona = {
apiKey: string;
};
/**
* Create Authorization
* Authorizes another Organization to access your Inquiry, Verifications, or other Persona resources.
*/
export async function main(
auth: Persona,
body: { "client-id": string; "response-type": string; scope: string },
Key_Inflection?: string,
Idempotency_Key?: string,
Persona_Version?: string,
) {
const url = new URL(`https://api.withpersona.com/api/v1/oauth/authorize`);
const headers: Record<string, string> = {
Authorization: `Bearer ${auth.apiKey}`,
"Content-Type": "application/x-www-form-urlencoded",
};
if (Key_Inflection) {
headers["Key-Inflection"] = Key_Inflection;
}
if (Idempotency_Key) {
headers["Idempotency-Key"] = Idempotency_Key;
}
if (Persona_Version) {
headers["Persona-Version"] = Persona_Version;
}
const response = await fetch(url, {
method: "POST",
headers,
body: new URLSearchParams(body as Record<string, string>),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 428 days ago