github-project-automation-plus: [BUG] ##[error]Parameter token or opts.auth is required

Resume

I’m receiving the error ##[error]Parameter token or opts.auth is required on this run on my CI

Proofs

image image

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?

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17 (8 by maintainers)

Most upvoted 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!

@rodrigondec some people had issues using GH_TOKEN and GITHUB_TOKEN can you try renaming your secret to something else? #33

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

image

image

@alex-page digged some other codes and docs. I edited the issue 😄

I think it is a tedious job to configure secret for all repositories of an organization. @alex-page is this intentionally or there is not a straight forward way to allow organization level token manage projects of all repositories.

On a personal note, I won’t like configuring secrets for all repositories individually.