Toolkit: [BUG] ##[error]Parameter token or opts.auth is required

Created on 18 May 2020  路  2Comments  路  Source: actions/toolkit

Describe the bug
I reported this bug on the action I'm using: alex-page/github-project-automation-plus#39.

read this issue to have better understanding of the discussions we had.

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

I found this issue actions/toolkit#324 by googling the error returned.

On this line of code of the action I'm using 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`.

To Reproduce
Steps to reproduce the behavior:

  1. Go to this run
  2. Click on 're-run all jobs'
  3. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
image
image

Additional context
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 issue be opened on @ocktokit/core?

bug

All 2 comments

Hey @rodrigondec,

I think you are encountering a different issue here. For security, Secrets are not currently available to forks.

This call to getInput is likely returning the empty string.

const octokit = new github.GitHub(""), will return that error message.

The forked repo likely does not have this secret set.

We are currently evaluating features to enable secrets in forks

Hey @rodrigondec,

I think you are encountering a different issue here. For security, Secrets are not currently available to forks.

This call to getInput is likely returning the empty string.

const octokit = new github.GitHub(""), will return that error message.

The forked repo likely does not have this secret set.

We are currently evaluating features to enable secrets in forks

It makes sense. Ty for the response.

Was this page helpful?
0 / 5 - 0 ratings