mirror of
https://github.com/github/codeql-action.git
synced 2025-12-26 17:20:10 +08:00
37 lines
853 B
JavaScript
37 lines
853 B
JavaScript
import { request as defaultRequest } from "@octokit/request";
|
|
async function scopeToken(options) {
|
|
const {
|
|
request: optionsRequest,
|
|
clientType,
|
|
clientId,
|
|
clientSecret,
|
|
token,
|
|
...requestOptions
|
|
} = options;
|
|
const request = options.request || defaultRequest;
|
|
const response = await request(
|
|
"POST /applications/{client_id}/token/scoped",
|
|
{
|
|
headers: {
|
|
authorization: `basic ${btoa(`${clientId}:${clientSecret}`)}`
|
|
},
|
|
client_id: clientId,
|
|
access_token: token,
|
|
...requestOptions
|
|
}
|
|
);
|
|
const authentication = Object.assign(
|
|
{
|
|
clientType,
|
|
clientId,
|
|
clientSecret,
|
|
token: response.data.token
|
|
},
|
|
response.data.expires_at ? { expiresAt: response.data.expires_at } : {}
|
|
);
|
|
return { ...response, authentication };
|
|
}
|
|
export {
|
|
scopeToken
|
|
};
|