code-server: [Bug]: Login GitHub

Is there an existing issue for this?

  • I have searched the existing issues

OS/Web Information

  • Web Browser: Version 1.34.81 Chromium: 97.0.4692.99 (Build officiel) (64 bits)
  • Local OS: Windows 10
  • Remote OS: Docker (codercom/code-server:latest)
  • Remote Architecture:
  • code-server --version: 4.0.1

Steps to Reproduce

  1. git push -u origin main

Expected

Have github authentication message

Actual

Error committing github

Logs

No response

Screenshot/Video

image image image

Does this issue happen in VS Code?

  • I cannot reproduce this in VS Code.

Are you accessing code-server over HTTPS?

  • I am using HTTPS.

Notes

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 12
  • Comments: 27 (11 by maintainers)

Commits related to this issue

Most upvoted comments

Heads-up: for anyone else experiencing this, please give a thumbs-up on the issue description! That will help me see how many people are affected by this and prioritize properly.

Based on the reports, this might be due to our setup. I’m experiencing the same issue with my docker (codercom/code-server:latest) + nginx-proxy (with lets-encrypt support).

This issue happens on all browsers I tried (latest Chrome/Safari/Brave on macOS + Safari on iPad).

The workaround in #1883 still works. (Unfortunately the Github Login seems to be stored locally in the browser, which means I’d need to perform this everytime I’m switching clients. On the bright side, using inkognito mode should give you a ‘clean’ instance to reproduce @jsjoeio)

In my opinion storing and using a PAT on the server would be the best way, so I won’t need to re-authenticate when using a new client. (But I’m new to this project, so I have no idea if this is even remotely possible 😄 )

P.S.: About Screen:

code-server: v4.0.2
VS Code: v1.63.0
Commit: 5cdfe74686aa73e023f8354a9a6014eb30caa7dd
Date: 2022-01-27T22:22:39Z (3 wks ago)
Browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36

P.P.S: The request is similiar to the one above: https://vscode-auth.github.com/authorize/?callbackUri=https://coder.<domain>.net/callback%253Fvscode-requestId%<reqID>%2526vscode-scheme%253Dcode-oss%2526vscode-authority%253Dvscode.github-authentication%2526vscode-path%253D%25252Fdid-authenticate&scope=repo%20workflow&state=<state>&responseType=code&authServer=https://github.com

Build a little script using the method above to get the URL.

#!/bin/bash

read -p "VSCode GH Auth URL:" URL

STATE=$(echo $URL | awk -F'[=&]' '{print $6}')

NEW_URL="https://vscode-auth.github.com/authorize/?callbackUri=vscode://vscode.github-authentication/did-authenticate&scope=repo,workflow,read:user,user:email&state=${STATE}&responseType=code"

clear
echo 
echo "1. Access URL below & grant access"
echo
echo $NEW_URL
echo
echo "2. Don't use 'Open with VSCode...'"
echo "3. Copy the token."
echo "4. Switch back to VS code."
echo "5. Click Signing in to github.com... in the status bar."
echo "6. Paste the token and hit enter."

EDIT: As you can see this requests for scope=repo,workflow,read:user,user:email, since I’m using the Workflow Plugin and the Issues Plugin. scope=repo should be sufficient for the git integration.

Thank you @ricreis394 for the solution and @steilerDev for the killer script 🔥

Hoping this is a quick fix on our end. We had yesterday off but we’re back this week. Thanks for the patience!

A fix will be available in the next release!

If nothing else works, maybe having that within code-server could be the best solution?

Used the below method and worked as a temporary workaround

  1. CTRL + Shift + P ▶️ Publish to Github
  2. Will show a window asking permission to allow signin, press Allow
  3. Extract the state from the url opened and insert that in this url https://vscode-auth.github.com/authorize/?callbackUri=vscode://vscode.github-authentication/did-authenticate&scope=repo,workflow&state=<insert-state-from-code-server-here>&responseType=code
  4. open the new url in the browser, and allow sign in, after submitting it will generate a new url/code. Copy that generated url that will be something like this: vscode://vscode.github-authentication/did-authenticate?code=<code>&state=<state>
  5. go to code-server and click on “Signing in to GitHub” on the taskbar. It then will ask for the URI and paste the url
  6. And boom, you’re logged in!

Credits: https://github.com/coder/code-server/issues/1883#issuecomment-712595418

Hmm…you were very helpful with the video! I wish there was a way to reproduce it consistently. One thing you could do is grab the authorization URL that opens in the browser (be sure to remove the auth token from the URL) and share it here?

@jsjoeio

https://vscode-auth.github.com/authorize/?callbackUri=<ip>:8443/callback%253Fvscode-requestId%253D<hiddenRequestId>%2526vscode-scheme%253Dcode-oss%2526vscode-authority%253Dvscode.github-authentication%2526vscode-path%253D%25252Fdid-authenticate&scope=repo%20workflow&state=<hiddenState>&responseType=code&authServer=https://github.com

Not sure what to hide, so I hidden the requestId and the State

You are probably right about it being lost. I will need to be in this code soon for other reasons so I will take a look.

What happens if you hit cancel?

@jsjoeio It just cancels. Won’t do anything I’m using code behind a reverse proxy (nginx), at first I thought that could be the problem, but nope. The gif I sent is from direct IP connection, no redirections

The strange thing is, before version 4, I was logged in on github, don’t know why it logged out…

A fix will be available in the next release!

Thank you

Not sure if this helps, but I can push to GH using username and PAT after cancelling the default login option. However, it asks for the PAT each time I try to push a commit.

Information:

OS: Debian Bullseye Code-Server: Docker Container (Latest) Browser: iPad (Safari)

What happens if you open the Command Palette > “Publish to GitHub” > enter your PAT? Does that work?

@jsjoeio this method doesn’t work for me because the window doesn’t let me insert the PAT, it opens the error link directly

$ code-server --version
4.0.2 5cdfe74686aa73e023f8354a9a6014eb30caa7dd

image

Settings Sync

Happens on MacOS BigSur (11.4) and Arch Linux, both with firefox and vivaldi (code-server hosted on arch)