Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error "Bad Credentials" when running github action #1581

Closed
NikosDev opened this issue Dec 11, 2023 Discussed in #1580 · 1 comment
Closed

Error "Bad Credentials" when running github action #1581

NikosDev opened this issue Dec 11, 2023 Discussed in #1580 · 1 comment

Comments

@NikosDev
Copy link
Contributor

Discussed in #1580

Originally posted by NikosDev December 11, 2023
I have used the github action setup to create my metrics but it fails with error "Bad Credentials" when github action is triggered. I have created a secret in my repository called METRICS_TOKEN and assigned the token value.

My yaml file is this:

# Visit https://github.com/lowlighter/metrics#-documentation for full reference
name: Metrics
on:
  # Schedule updates (each hour)
  schedule: [{cron: "0 * * * *"}]
  # Lines below let you run workflow manually and on each commit
  workflow_dispatch:
  push: {branches: ["master", "main"]}
jobs:
  github-metrics:
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - uses: lowlighter/metrics@latest
        with:
          # Your GitHub token
          # The following scopes are required:
          #  - public_access (default scope)
          # The following additional scopes may be required:
          #  - read:org      (for organization related metrics)
          #  - read:user     (for user related data)
          #  - read:packages (for some packages related data)
          #  - repo          (optional, if you want to include private repositories)
          token: ${{ secrets.METRICS_TOKEN }}

          # Options
          user: NikosDev
          template: classic
          base: header, activity, community, repositories, metadata
          config_timezone: Europe/Athens

My github action error:
image

Github action error log:

─────
Metrics                                                         │  
Setup                                                           │ complete
Version                                                         │ 3.34.0
Using prebuilt image                                            │ true
Debug mode                                                      │ false
Debug flags                                                     │ (none)
GitHub token                                                    │ (provided)
GitHub token format                                             │ classic
GitHub GraphQL API                                              │ ok
GitHub GraphQL API endpoint                                     │ (default)
GitHub REST API                                                 │ ok
GitHub REST API endpoint                                        │ (default)
API requests (REST)                                             │ (unknown)
API requests (GraphQL)                                          │ (unknown)
API requests (Search)                                           │ (unknown)
Token validity                                                  │ (could not verify)
GitHub account                                                  │ NikosDev
Current repository                                              │ NikosDev/NikosDev
Committer token                                                 │ (provided)
Committer branch                                                │ main
Committer head branch                                           │ main
Committer REST API                                              │ ok
Committer account                                               │ (github-actions)
Committer head branch status                                    │ ok
Previous render sha                                             │ (none)
SVG output                                                      │ github-metrics.svg
SVG optimization                                                │ css, xml
SVG verification after generation                               │ false
────────────────────────────────────────────────────────────────────────────────────────
Templates                                                       │  
Community templates                                             │ (none)
Template used                                                   │ classic
Query additional params                                         │ {}
────────────────────────────────────────────────────────────────────────────────────────
Core                                                            │  
Markdown template path                                          │ TEMPLATE.md
Extra CSS                                                       │ 
Extra JavaScript                                                │ 
Timezone for dates                                              │ Europe/Athens
Plugin order                                                    │ 
Use twemojis                                                    │ false
Use GitHub custom emojis                                        │ true
Use GitHub octicons                                             │ false
Display width (for image output formats)                        │ regular
Use CSS animations                                              │ true
Base64-encoded images                                           │ true
Output padding                                                  │ 0, 8 + 11%
Output format                                                   │ auto
Configuration presets                                           │ 
Notice about new releases of metrics                            │ true
Experimental features                                           │ 
Plugin errors                                                   │ (displayed in generated image)
────────────────────────────────────────────────────────────────────────────────────────
Base content                                                    │  
Fetched repositories                                            │ 100
Indepth mode                                                    │ false
Show `Available for hire!` in header section                    │ false
Skip base content                                               │ false
Fetched repositories per query                                  │ 100
Include forks                                                   │ false
Repositories affiliations                                       │ owner
Default skipped repositories                                    │ 
Default ignored users                                           │ github-actions[bot],dependabot[bot],dependabot-preview[bot],actions-user,action@github.com
Identifiers that has been used for authoring commits            │ .user.login
Base sections                                                   │ header, activity, community, repositories, metadata
────────────────────────────────────────────────────────────────────────────────────────
Rendering                                                       │  
RequestError [HttpError]: Bad credentials
    at /metrics/node_modules/@octokit/graphql/node_modules/@octokit/request/dist-node/index.js:112:21
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.default [as base] (file:///metrics/source/plugins/base/index.mjs:32:23)
    at async metrics (file:///metrics/source/app/metrics/index.mjs:79:5)
    at async retry.retries.retries (file:///metrics/source/app/action/index.mjs:407:40)
    at async retry (file:///metrics/source/app/action/index.mjs:57:22)
    at async file:///metrics/source/app/action/index.mjs:406:28 {
────────────────────────────────────────────────────────────────────────────────────────
undefined
An error occurred, logging debug message :
TypeError: Cannot read properties of null (reading 'oid')
    at file:///metrics/source/app/action/index.mjs:307:38
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Attempt 1/3
  metrics/compute/NikosDev > start
  {
    template: 'classic',
    'debug.flags': '',
    markdown: 'TEMPLATE.md',
    'extras.css': '',
    'extras.js': '',
    'config.timezone': 'Europe/Athens',
    'config.order': [],
    'config.twemoji': false,
    'config.gemoji': true,
    'config.octicon': false,
    'config.display': 'regular',
    'config.animations': true,
    'config.base64': true,
    'config.padding': '0, 8 + 11%',
    'config.output': 'auto',
    'config.presets': [],
    'notice.releases': true,
    'experimental.features': [],
    hireable: false,
    skip: false,
    'repositories.batch': 100,
    'repositories.forks': false,
    'repositories.affiliations': [ 'owner' ],
    'repositories.skipped': [],
    'users.ignored': [
      'github-actions[bot]',
      'dependabot[bot]',
      'dependabot-preview[bot]',
      'actions-user',
      'action@github.com'
    ],
    'commits.authoring': [ '.user.login' ],
    base: false,
    'base.header': true,
    'base.activity': true,
    'base.community': true,
    'base.repositories': true,
    'base.metadata': true,
    'base.indepth': false
  }
  metrics/compute/NikosDev > output format set to svg
  metrics/compute/NikosDev > content order : base.header,introduction,base.activity+community,base.repositories,lines,followup,discussions,languages,notable,projects,repositories,gists,pagespeed,habits,topics,music,nightscout,posts,rss,tweets,isocalendar,calendar,stars,starlists,stargazers,people,activity,reactions,anilist,wakatime,skyline,support,stackoverflow,leetcode,stock,achievements,screenshot,code,chess,sponsors,sponsorships,poopmap,16personalities,fortune,splatoon,steam
  metrics/compute/NikosDev > compute
  metrics/compute/NikosDev/base > started
  metrics/compute/NikosDev/base > affiliations constraints , ownerAffiliations: [OWNER], affiliations: [OWNER]
  metrics/compute/NikosDev/base > account user
  metrics/compute/NikosDev/base > account user > failed : HttpError: Bad credentials
Warning: Bad credentials
Attempt 2/3
Warning: Bad credentials
Attempt 3/3
Warning: Bad credentials
Error: Bad credentials
Error: Process completed with exit code 1.
```</div>
@NikosDev
Copy link
Contributor Author

I solved the issue by adding an environment key-value to the yaml file 🎉🎉🎉

This is my working yaml file:

# Visit https://github.com/lowlighter/metrics#-documentation for full reference
name: Metrics
on:
  # Schedule updates (each hour)
  schedule: [{cron: "0 * * * *"}]
  # Lines below let you run workflow manually and on each commit
  workflow_dispatch:
  push: {branches: ["master", "main"]}
jobs:
  github-metrics:
    runs-on: ubuntu-latest
    environment: 
      name: production
    permissions:
      contents: write
    steps:
      - uses: lowlighter/metrics@latest
        with:
          # Your GitHub token
          # The following scopes are required:
          #  - public_access (default scope)
          # The following additional scopes may be required:
          #  - read:org      (for organization related metrics)
          #  - read:user     (for user related data)
          #  - read:packages (for some packages related data)
          #  - repo          (optional, if you want to include private repositories)
          token: ${{ secrets.METRICS_TOKEN }}

          # Options
          user: NikosDev
          template: classic
          base: header, activity, community, repositories, metadata
          config_timezone: Europe/Athens

And this is the METRICS_TOKEN that i specified in my personal repository:
image

@github-actions github-actions bot locked and limited conversation to collaborators Jun 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant