在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:octokit/auth-action.js开源软件地址:https://github.com/octokit/auth-action.js开源编程语言:TypeScript 100.0%开源软件介绍:auth-action.js
It does not require any configuration, but instead reads the
UsageInstall with const { createActionAuth } = require("@octokit/auth-action");
// or: import { createActionAuth } from "@octokit/auth-action";
const auth = createActionAuth();
const authentication = await auth();
// {
// type: 'token',
// token: 'v1.1234567890abcdef1234567890abcdef12345678',
// tokenType: 'oauth'
// }
|
name | type | description |
---|---|---|
type
|
string
|
"token"
|
token
|
string
|
The provided token. |
tokenType
|
string
|
Can be either "oauth" for personal access tokens and OAuth tokens, or "installation" for installation access tokens (includes GITHUB_TOKEN provided to GitHub Actions)
|
auth.hook(request, route, options)
or auth.hook(request, options)
auth.hook()
hooks directly into the request life cycle. It authenticates the request using the provided token.
The request
option is an instance of @octokit/request
. The route
/options
parameters are the same as for the request()
method.
auth.hook()
can be called directly to send an authenticated request
const { data: authorizations } = await auth.hook(
request,
"GET /authorizations"
);
Or it can be passed as option to request()
.
const requestWithAuth = request.defaults({
request: {
hook: auth.hook,
},
});
const { data: authorizations } = await requestWithAuth("GET /authorizations");
auth()
does not send any requests, it only retrieves the token from the environment variable and transforms the provided token string into an authentication object.
The GITHUB_TOKEN
provided to GitHub Actions is an installation token with all permissions provided. You can use it for git
commands, too. Learn more about the differences in token authentication at @octokit/auth-action.
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论