[BUG] ##[error]Parameter token or opts.auth is required
See original GitHub issueResume
I’m receiving the error ##[error]Parameter token or opts.auth is required
on this run on my CI
Proofs
Description & code digging
I found this issue actions/toolkit#324 by googling the error returned.
On this line of code of this action is used:
const octokit = new github.GitHub(token);
In the package @actions/github
on this line of code (which probably raises the error) is used:
constructor(token: string, opts?: Omit<Octokit.Options, 'auth'>)
constructor(opts: Octokit.Options)
constructor(token: string | Octokit.Options, opts?: Octokit.Options) {
super(GitHub.getOctokitOptions(GitHub.disambiguate(token, opts)))
this.graphql = GitHub.getGraphQL(GitHub.disambiguate(token, opts))
}
Github extends Ocktokit. So is super = Ocktokit
In the package @ocktokit/core
on this line of code there’s the following explanation/documentation:
constructor(options: OctokitOptions = {}) {
[...]
// (1) If neither `options.authStrategy` nor `options.auth` are set, the `octokit` instance
// is unauthenticated. The `this.auth()` method is a no-op and no request hook is registred.
// (2) If only `options.auth` is set, use the default token authentication strategy.
// (3) If `options.authStrategy` is set then use it and pass in `options.auth`. Always pass own request as many strategies accept a custom request instance.
// TODO: type `options.auth` based on `options.authStrategy`.
Questions
Should be passed others args besides the token on this line from the action?
const octokit = new github.GitHub(token);
The construct does accept other options:
constructor(token: string, opts?: Omit<Octokit.Options, 'auth'>)
On the official documentation of @actions/github
is used only token
on the constructor.
Did we miss some official documentation? Should issues be opened on @actions/github
and @ocktokit/core
?
Issue Analytics
- State:
- Created 3 years ago
- Comments:17 (8 by maintainers)
Top GitHub Comments
I just ran into this error as well. I had stored the
GH_TOKEN
at the org-level initially. When I moved it to a repo-level secret, the action worked!Sure, I’ll modify and post the results.
But if this is the cause the problem lies on the lib used (
@actions/github
and@ocktokit/core
).Considering I’m using
GH_TOKEN
on my other projects and it’s working perfectly fine.https://github.com/imobanco/icnab240/runs/679469380?check_suite_focus=true
Proof