athul / waka-readme

Wakatime Weekly Metrics on your Profile Readme.
https://github.com/athul
MIT License
1.56k stars 301 forks source link

Authentication issues when renewing GH_TOKEN #141

Closed Sam54000 closed 1 year ago

Sam54000 commented 1 year ago

Hi, I have been using the workflow for a while now. As my GH_TOKEN expires I renewed it as usual (and I took care to tick the correct permissions). But since recently the workflow throw a 403 error telling me that the access is denied: 522 CRITICAL 403 {"message": "Resource not accessible by integration", "documentation_url": "https://docs.github.com/rest/repos/contents#create-or-update-file-contents"}

Do you have any idea of what it would be?

Here is the log

[2023-08-15 20:19:50] ln. 505 DEBUG    Initialize WakaReadme
[2023-08-15 20:19:50] ln. 163 DEBUG    Validating input variables
[2023-08-15 20:19:50] ln. 229 DEBUG    Input validation complete

[2023-08-15 20:19:50] ln. 465 DEBUG    Connecting to GitHub
[2023-08-15 20:19:50] ln. 471 DEBUG    Decoding readme contents

[2023-08-15 20:19:50] ln. 349 DEBUG    Pulling WakaTime stats from all time
[2023-08-15 20:19:50] ln. 364 DEBUG    API response #1: 200 • OK
[2023-08-15 20:19:50] ln. 368 DEBUG    Fetched WakaTime statistics

[2023-08-15 20:19:50] ln. 280 DEBUG    Making contents
Total Time: 519 hrs 2 mins
[2023-08-15 20:19:50] ln. 262 DEBUG    Generating graph for 'Python'

[2023-08-15 20:19:50] ln. 270 DEBUG    'Python' graph generated
Python          454 hrs 53 mins ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣀⣀⣀   87.64 %
[2023-08-15 20:19:50] ln. 262 DEBUG    Generating graph for 'Vim Script'
Vim Script      42 hrs 11 mins  ⣿⣿⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀   08.13 %
[2023-08-15 20:19:50] ln. 270 DEBUG    'Vim Script' graph generated
Other           11 hrs 45 mins  ⣦⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀   02.26 %
[2023-08-15 20:19:50] ln. 262 DEBUG    Generating graph for 'Other'

[2023-08-15 20:19:50] ln. 270 DEBUG    'Other' graph generated
[2023-08-15 20:19:50] ln. 337 DEBUG    Contents were made

[2023-08-15 20:19:50] ln. 478 DEBUG    WakaReadme stats has changed
[2023-08-15 20:19:51] ln. 522 CRITICAL 403 {"message": "Resource not accessible by integration", "documentation_url": "https://docs.github.com/rest/repos/contents#create-or-update-file-contents"}

Here is the yml file:

name: Waka Readme

on:
  workflow_dispatch:
  schedule:
    - cron: "0 0 * * *"

jobs:
  update-readme:
    name: WakaReadme DevMetrics
    runs-on: ubuntu-latest
    steps:
      - uses: athul/waka-readme@master
        with:
          WAKATIME_API_KEY: ${{ secrets.WAKATIME_API_KEY }}
          GH_TOKEN: ${{ secrets.GH_TOKEN }}
          API_BASE_URL: https://wakatime.com/api
          REPOSITORY: Sam54000/Sam54000
          SHOW_TITLE: false
          BLOCKS: ⣀⣄⣤⣦⣶⣷⣿
          TIME_RANGE: all_time
          SHOW_TIME: true
          SHOW_MASKED_TIME: true
          LANG_COUNT: 3
          COMMIT_MESSAGE: Updated waka-readme graph with new metrics
          TARGET_BRANCH: main
          TARGET_PATH: README.md
          COMMITTER_NAME: GitHubActionBot
          COMMITTER_EMAIL: action-bot@github.org
          AUTHOR_NAME: Sam54000
          AUTHOR_EMAIL: <my_email>

Thanks

yozachar commented 1 year ago

Hi @Sam54000, refer https://github.com/athul/waka-readme/issues/114#issuecomment-1398053158. You really do not need GH_TOKEN on profile readme.


But if you want to use it, your token access summary should be like so.

image

Sam54000 commented 1 year ago

Hi @joe733 I tried without the GH_TOKEN but somewhat it wasn't working either. I tried the Fine-grained token instead of the Classic one and now it works. Thanks!

yozachar commented 1 year ago

Without GH_TOKEN you need to set read-write permission in Code and automation → Actions → General → Workflow permissions section of your profile repository settings. Anyway glad it worked, thanks for using waka-readme!

Leeon-K commented 1 year ago

Without GH_TOKEN you need to set read-write permission in Code and automation → Actions → General → Workflow permissions section of your profile repository settings. Anyway glad it worked, thanks for using waka-readme!

Thank you, it works!!