type Github = {
token: string;
};
/**
* Check a token
* OAuth applications can use a special API method for checking OAuth token validity without exceeding the normal rate limits for failed login attempts.
*/
export async function main(
auth: Github,
client_id: string,
body: { access_token: string; [k: string]: unknown }
) {
const url = new URL(`https://api.github.com/applications/${client_id}/token`);
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 314 days ago
type Github = {
token: string;
};
/**
* Check a token
* OAuth applications can use a special API method for checking OAuth token validity without exceeding the normal rate limits for failed login attempts.
*/
export async function main(
auth: Github,
client_id: string,
body: { access_token: string; [k: string]: unknown }
) {
const url = new URL(
`https://api.github.com/applications/${client_id}/auth.auth.auth.token`
);
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 319 days ago