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

Cannot sign in to Github account #1883

Closed
subhamayd2 opened this issue Jul 16, 2020 · 23 comments
Closed

Cannot sign in to Github account #1883

subhamayd2 opened this issue Jul 16, 2020 · 23 comments
Assignees
Labels
bug Something isn't working high-priority This issue needs to be resolved ASAP
Projects
Milestone

Comments

@subhamayd2
Copy link

Cannot sign in to Github.
When I click on "Clone repository" under SCM tab and provide the repo url and folder, it asks me to sign in to Github.
The authorization page opens in a new tab:
image

After clicking on "Continue", the following error occurs:
image

I tried to generate "Personal Access Token" on Github, then entered that here:
image

This did not work either.

  • Web Browser: Microsoft Egde (Chromium)
  • Local OS: Windows 10
  • Remote OS: Ubuntu 18.04.3 (LTS)
  • Remote Architecture: x64
  • code-server --version: 3.4.1
@code-asher code-asher added the bug Something isn't working label Jul 16, 2020
@code-asher
Copy link
Member

Definitely need to look into this, I took a swing a few weeks ago but wasn't able to figure it out at the time.

@jinexists-oldaccount
Copy link

I had the same issue and was able to figure out a solution. I took the url that a regular instance of VSCode spits out and used it to reverse engineer how the url is put together.

A auth url from code-server looks like this:
https://vscode-auth.github.com/authorize/?callbackUri=https://example.com/callback%3Fvscode-requestId%xxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx%26vscode-scheme%3Dcode-oss%26vscode-authority%3Dvscode.github-authentication%26vscode-path%3D%252Fdid-authenticate&scope=repo&state=state-from-code-server&responseType=code

What I did was take the state parameter at the end of the auth url given by code-server and insert it into the url below which is derived from the url a normal version of VSCode spits out.

A final url will look like this:
https://vscode-auth.github.com/authorize/?callbackUri=vscode://vscode.github-authentication/did-authenticate&scope=repo&state=insert-state-from-code-server-here&responseType=code

After going to the page you will get an auth token that looks something like this:
vscode://vscode.github-authentication/did-authenticate?code=secretcode&state=magicstate

Then, back in code-server you can click signing into github.com in the task bar and paste the auth token.

Hope this helps!

@subhamayd2
Copy link
Author

@jinexists Thanks. It works. 😁

@nhooyr
Copy link
Contributor

nhooyr commented Jul 21, 2020

So I guess we're spitting out the URL incorrectly for some reason.

@code-asher
Copy link
Member

code-asher commented Jul 21, 2020

Looking at that URL, maybe we need to add a handler for vscode://?

Related: #1571

@imnobaka
Copy link

imnobaka commented Jul 28, 2020

OMG, I just couldn't find your post on my own googling. Luckily Quietsy from the linuxserver group helped point me your way. I will say that the structure changed a little bit for me so I'll paste my case for future reference. Thank you again for troubleshooting this.

https://vscode-auth.github.com/authorize/?callbackUri=vscode://vscode.github-authentication/did-authenticate&scope=repo&state=PASTE-CODE-HERE&responseType=code

https://vscode-auth.github.com/authorize/?callbackUri=https://code.example.com/callback%XXXXX-requestId%XXXXX-XXXXXX-XXXXX%26vscode-scheme%3XXXX-XXXX%26vscode-authority%XXXXXXgithub-authentication%26vscode-path%3D%252Fdid-authenticate&scope=read:user repo user:email&state=COPY-CODE-HERE&responseType=code

@mal5305
Copy link

mal5305 commented Aug 25, 2020

thanks for the workaround, worked for me! this was driving me nuts!

@agneevX
Copy link

agneevX commented Aug 27, 2020

I get this error:

The input did not matched the expected format

Is there absolutely no way add GitHub sign-in other than this?

@Heath123
Copy link

Heath123 commented Aug 28, 2020

I can confirm this bug (it's probably already confirmed enough though)

@nhooyr nhooyr added this to the v3.5.1 milestone Aug 31, 2020
@garyhtou
Copy link

I had the same issue and was able to figure out a solution. I took the url that a regular instance of VSCode spits out and used it to reverse engineer how the url is put together.

A auth url from code-server looks like this:
https://vscode-auth.github.com/authorize/?callbackUri=https://example.com/callback%3Fvscode-requestId%xxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx%26vscode-scheme%3Dcode-oss%26vscode-authority%3Dvscode.github-authentication%26vscode-path%3D%252Fdid-authenticate&scope=repo&state=state-from-code-server&responseType=code

What I did was take the state parameter at the end of the auth url given by code-server and insert it into the url below which is derived from the url a normal version of VSCode spits out.

A final url will look like this:
https://vscode-auth.github.com/authorize/?callbackUri=vscode://vscode.github-authentication/did-authenticate&scope=repo&state=insert-state-from-code-server-here&responseType=code

After going to the page you will get an auth token that looks something like this:
vscode://vscode.github-authentication/did-authenticate?code=secretcode&state=magicstate

Then, back in code-server you can click signing into github.com in the task bar and paste the auth token.

Hope this helps!

It gave me Sign in failed: Error: network error

@raestrada95
Copy link

I had the same issue and was able to figure out a solution. I took the url that a regular instance of VSCode spits out and used it to reverse engineer how the url is put together.

A auth url from code-server looks like this:
https://vscode-auth.github.com/authorize/?callbackUri=https://example.com/callback%3Fvscode-requestId%xxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx%26vscode-scheme%3Dcode-oss%26vscode-authority%3Dvscode.github-authentication%26vscode-path%3D%252Fdid-authenticate&scope=repo&state=state-from-code-server&responseType=code

What I did was take the state parameter at the end of the auth url given by code-server and insert it into the url below which is derived from the url a normal version of VSCode spits out.

A final url will look like this:
https://vscode-auth.github.com/authorize/?callbackUri=vscode://vscode.github-authentication/did-authenticate&scope=repo&state=insert-state-from-code-server-here&responseType=code

After going to the page you will get an auth token that looks something like this:
vscode://vscode.github-authentication/did-authenticate?code=secretcode&state=magicstate

Then, back in code-server you can click signing into github.com in the task bar and paste the auth token.

Hope this helps!

Hi i appreciate the help this solution worked perfect for me.

@bt
Copy link

bt commented Sep 23, 2020

I had the same issue and was able to figure out a solution. I took the url that a regular instance of VSCode spits out and used it to reverse engineer how the url is put together.

A auth url from code-server looks like this:
https://vscode-auth.github.com/authorize/?callbackUri=https://example.com/callback%3Fvscode-requestId%xxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx%26vscode-scheme%3Dcode-oss%26vscode-authority%3Dvscode.github-authentication%26vscode-path%3D%252Fdid-authenticate&scope=repo&state=state-from-code-server&responseType=code

What I did was take the state parameter at the end of the auth url given by code-server and insert it into the url below which is derived from the url a normal version of VSCode spits out.

A final url will look like this:
https://vscode-auth.github.com/authorize/?callbackUri=vscode://vscode.github-authentication/did-authenticate&scope=repo&state=insert-state-from-code-server-here&responseType=code

After going to the page you will get an auth token that looks something like this:
vscode://vscode.github-authentication/did-authenticate?code=secretcode&state=magicstate

Then, back in code-server you can click signing into github.com in the task bar and paste the auth token.

Hope this helps!

I just tried this and it works, thanks. However, it seems like private repositories don't load up in the search results and therefore I cannot clone a private repository.

@code-asher code-asher self-assigned this Oct 5, 2020
@TristanBrotherton
Copy link

I am also blocked by this error. The workaround failed, and gave me the error “Sign in Failed: Received mismatched state”.

@nhooyr nhooyr modified the milestones: v3.6.0, v3.6.1 Oct 9, 2020
@gmrukwa
Copy link

gmrukwa commented Oct 20, 2020

If anyone wants to modify GitHub workflow files, I modified the URL a bit:

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

@edi
Copy link

edi commented Nov 6, 2020

I can confirm the structure mentionde by @gmrukwa works fine 👍🏻

@bt You need to type in the actual repo name, as by default, only public repos will initially show up in the search result. Otherwise, if it still doesn't work, try adding "scope=repo**,wokflow**" instead of just repo to the sign in callback URL, as mentioend in @gmrukwa's answer.

I've tried it and works fine cloning private repos.

Regards!

@nhooyr nhooyr modified the milestones: v3.6.3, v3.6.4 Nov 13, 2020
@nhooyr nhooyr added this to To do in code-server via automation Dec 8, 2020
@nhooyr nhooyr added the high-priority This issue needs to be resolved ASAP label Dec 8, 2020
@nhooyr nhooyr moved this from To do to Next in code-server Dec 8, 2020
@nhooyr nhooyr moved this from Next to In progress in code-server Dec 8, 2020
code-server automation moved this from In progress to Done Dec 18, 2020
@TristanBrotherton
Copy link

After updating code-server and attempting to auth with github I get a 404 on my code-server instance:

ENOENT: no such file or directory, stat '/usr/lib/code-server/lib/vscode/resources/web/callback.html'

@Craftzman7
Copy link

Still experiencing this

@Rintrium
Copy link

Same problem here. Rewriting the link like @gmrukwa suggested and pasting the result worked (you don't have that much time to enter it in vscode; an error will occur otherwise).

@vordenken
Copy link

Unfortunately the workaround doesn't work for me.
I installed code-server using the script & reverseproxying with nginx (if this is relevant).

Pasting the vscode:// part after clicking on "Signing in to GitHub.com..." doesn't do anything, no error message. A few seconds later the "Signing in to GitHub.com"-party disappears but I'm not logged in.

@gmrukwa
Copy link

gmrukwa commented Jan 17, 2022

@vordenken that may depend on the versions you are using. I've created myself another instruction for newer version recently:

1. Try `git clone` in the VS Code instance console.
2. The popup will appear to authenticate to GitHub.
3. Allow the extension to authenticate (it doesn't look very convincing, but
this is the account of the VS Code Server author)
4. You will be redirected to a non-working page. Do not close it.
5. Copy the browser address of your VS Code instance & paste it instead the
part before `/callback(...)` part of the non-working page. Do not close it.
6. At the end of the address there will be `?code=(...)&state=(...)`,
copy these.
7. Go to the VS Code instance.
8. In the status bar there's something like `GitHub: authenticating...`,
click it.
9. Paste values to the format
`vscode://vscode.github-authentication/did-authenticate?code=(...)&(...)`
and put into the popup.
10. Voila, you are logged in.

It's a bit different than the workaround above, there are slightly different URIs.

The above stopped working for me too some time ago already, so now I've set up git credentials helper to store my credentials, and when Signing in to GitHub.com... is about to fail, it asks for username and password. You can generate your personal access token on GitHub and use it there. The credential helper will take care of the remaining stuff. Just remember, that the credentials will be stored in the container, so it may be a security issue if you plan to share the container.

@chientrm
Copy link

I had the same issue and was able to figure out a solution. I took the url that a regular instance of VSCode spits out and used it to reverse engineer how the url is put together.

A auth url from code-server looks like this: https://vscode-auth.github.com/authorize/?callbackUri=https://example.com/callback%3Fvscode-requestId%xxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx%26vscode-scheme%3Dcode-oss%26vscode-authority%3Dvscode.github-authentication%26vscode-path%3D%252Fdid-authenticate&scope=repo&state=state-from-code-server&responseType=code

What I did was take the state parameter at the end of the auth url given by code-server and insert it into the url below which is derived from the url a normal version of VSCode spits out.

A final url will look like this: https://vscode-auth.github.com/authorize/?callbackUri=vscode://vscode.github-authentication/did-authenticate&scope=repo&state=insert-state-from-code-server-here&responseType=code

After going to the page you will get an auth token that looks something like this: vscode://vscode.github-authentication/did-authenticate?code=secretcode&state=magicstate

Then, back in code-server you can click signing into github.com in the task bar and paste the auth token.

Hope this helps!

Sorry for comment to a closed issue. I confirm this solution still works. However, I need to copy paste quickly. Otherwise, the state expires in seconds.

@steilerDev
Copy link

Any reason why this has been closed? I am still experiencing this issue. (or is this a technical limitation?)

The workaround above still works, but this is very tedious, especially since it seems that the authentication is not stored on the server but the client (which means I need to use the workaround on an iPad which is a pain...)

@jsjoeio
Copy link
Contributor

jsjoeio commented Feb 17, 2022

Any reason why this has been closed?

It was closed when we fixed it.

There's also another issue we're tracking this in here: #4795

Please subscribe to that! It should fix this tedious process and make it work as expected :) (less of a pain on an iPad too!)

@coder coder locked as resolved and limited conversation to collaborators Feb 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working high-priority This issue needs to be resolved ASAP
Projects
No open projects
Development

No branches or pull requests