mirror of
https://github.com/github/codeql-action.git
synced 2025-12-27 01:30:10 +08:00
30 lines
860 B
JavaScript
30 lines
860 B
JavaScript
import { request as defaultRequest } from "@octokit/request";
|
|
async function checkToken(options) {
|
|
const request = options.request || defaultRequest;
|
|
const response = await request("POST /applications/{client_id}/token", {
|
|
headers: {
|
|
authorization: `basic ${btoa(
|
|
`${options.clientId}:${options.clientSecret}`
|
|
)}`
|
|
},
|
|
client_id: options.clientId,
|
|
access_token: options.token
|
|
});
|
|
const authentication = {
|
|
clientType: options.clientType,
|
|
clientId: options.clientId,
|
|
clientSecret: options.clientSecret,
|
|
token: options.token,
|
|
scopes: response.data.scopes
|
|
};
|
|
if (response.data.expires_at)
|
|
authentication.expiresAt = response.data.expires_at;
|
|
if (options.clientType === "github-app") {
|
|
delete authentication.scopes;
|
|
}
|
|
return { ...response, authentication };
|
|
}
|
|
export {
|
|
checkToken
|
|
};
|