leetcode-sync
leetcode-sync copied to clipboard
Error: Error: Request failed with status code 401
Sorry! After I follow your tutorial, I always get this error and I don't know how to deal with it.
sync_leetcode.yml
# This is a basic workflow to help you get started with Actions
name: Sync Leetcode
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab
# cron: 'min hour day month week (year)'
workflow_dispatch:
schedule:
- cron: '5 * * * *'
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
# - uses: actions/checkout@v3
# Runs a single command using the runners shell
# - name: Run a one-line script
# run: echo Hello, world!
# # Runs a set of commands using the runners shell
# - name: Run a multi-line script
# run: |
# echo Add other actions to build,
# echo test, and deploy your project.
- name: Sync
uses: joshcai/[email protected]
with:
github-token: ${{ github.token }}
leetcode-csrf-token: ${{ secrets.LEETCODE_CSRF_TOKEN }}
leetcode-session: ${{ secrets.LEETCODE_SESSION }}
destination-folder: my-folder
#
And these file's contents are:
I don't know what went wrong.
Thank you for your help!
Hi @doubley318, I unfortunately don't see anything wrong from the screenshots you provided - one thing you could try is to run this Chrome extension instead: https://github.com/joshcai/leetcode-sync-chrome/releases/tag/v0.0.1
It should set up all the variables for you in case there were any issues with copying the values over.
Even I was facing this issue. It got fixed when I updated my secret with the latest values... Probably the cookie values expired.
Two weeks later I encountered the same error. It looks like the token or session expires after 2 weeks.
Do you think it's possible to fetch the token systematically from Leetcode?
This seems to be a unique problem of Chinese leetcode. I encountered the same error for https://leetcode.cn/, but https://leetcode.com/, it works.
Two weeks later I encountered the same error. It looks like the token or session expires after 2 weeks.
Same here, looks like LeeetCode session has an expiry of two weeks. Once I update the value of LeetCode session in "Actions secrets and variables" it works fine. (Using https://leetcode.com)
Added the issue here with details - #39
I faced this within a span of a few hours of running the action successfully today even though I had set the LEETCODE_SESSION and CSRF_TOKEN values just yesterday. Updating these two values resolved the issue, even though the time span was certainly not two weeks!
I faced this within a span of a few hours of running the action successfully today even though I had set the LEETCODE_SESSION and CSRF_TOKEN values just yesterday. Updating these two values resolved the issue, even though the time span was certainly not two weeks!
I believe what happened was that the values already had a set date to expire when you obtained them. So you probably obtained them just a day before the expiry date. The validity of the values should certainly last more than a few days. Hope this helps!
Helpful!