Skip to content

Error: Error: Request failed with status code 401 #18

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

Open
doubley318 opened this issue May 9, 2022 · 9 comments
Open

Error: Error: Request failed with status code 401 #18

doubley318 opened this issue May 9, 2022 · 9 comments

Comments

@doubley318
Copy link

Sorry! After I follow your tutorial, I always get this error and I don't know how to deal with it.
image
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
# 

image
And these file's contents are:
image
I don't know what went wrong.

Thank you for your help!

@joshcai
Copy link
Owner

joshcai commented May 9, 2022

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.

@vishrutkmr7
Copy link

Even I was facing this issue. It got fixed when I updated my secret with the latest values... Probably the cookie values expired.

@wmorgue
Copy link

wmorgue commented Sep 28, 2022

Two weeks later I encountered the same error. It looks like the token or session expires after 2 weeks.

@mue8010
Copy link

mue8010 commented Jan 15, 2023

Do you think it's possible to fetch the token systematically from Leetcode?

@zhangjie119
Copy link

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.

@jaspinderkohli
Copy link
Contributor

jaspinderkohli commented Jul 17, 2023

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

@now-youre-gittin-it
Copy link

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!

@chantellecv
Copy link

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!

@Wayne0758
Copy link

Helpful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants