Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Github "Sign in with browser" open localhost in browser, login fails #2521

Open
iozcelik opened this issue Jun 2, 2020 · 77 comments
Open

Github "Sign in with browser" open localhost in browser, login fails #2521

iozcelik opened this issue Jun 2, 2020 · 77 comments

Comments

@iozcelik
Copy link

iozcelik commented Jun 2, 2020

Versions

  • GitHub Extension for Visual Studio version: v2.11.96
  • Visual Studio version: 16.6.0

What happened

Steps to Reproduce

Steps to reproduce the behavior:

  1. Go to 'Team Explorer'
  2. Click on 'Connect...' button inside Github panel
  3. Click on 'Sign in with browser'
  4. Browser open tab with localhost address
  5. Connection fails

Expected behavior

Open to a github.com adress

Screenshots

github
adres

@jcansdale
Copy link
Collaborator

Hi @iozcelik,

I'm sorry you were experiencing this! Did you ever manage to get it to work?

@iozcelik
Copy link
Author

iozcelik commented Jul 8, 2020

Sign in with browser never worked at my computer.

@techduggu
Copy link

Note: Adding this comment here to provide more information (as already added into #2509 )

Hi Team,

Even I am facing this issue with GitHub extension with Visual Studio 2019. I have tried the above workarounds (uninstalling/reverting to previous version etc.) but no luck.

I am able to sign-in successfully to GitHub on my browser but through extension, when I click on 'Sign in with your browser' option, it opens the browser with the below URL and it just keeps loading:
https://github.com/login/oauth/authorize?client_id=a200baed193bb2088a6e&scope=user%2Crepo%2Cgist%2Cwrite%3Apublic_key%2Cread%3Aorg%2Cworkflow&state=cd3677b8-bf82-4d2d-80c2-71fb3ed7cb63

Below is the error captured from Github Extension log:

2020-08-15 22:29:05.832 [20420] INFO [58] GitHubPackage Initializing GitHub Extension v2.11.104.25275 in Microsoft Visual Studio 2019 (16.6.30114.105)
2020-08-15 22:29:23.860 [20420] EROR [01] LoginTabViewModel Error logging into '"https://github.com/"' as ''
Octokit.AuthorizationException: Requires authentication
at Octokit.Connection.HandleErrors(IResponse response)
at Octokit.Connection.d__58.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Octokit.Connection.d__571.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at GitHub.Api.LoginManager.<GetUserAndCheckScopes>d__23.MoveNext() in D:\a\VisualStudio\VisualStudio\src\GitHub.Api\LoginManager.cs:line 346 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at GitHub.Api.LoginManager.<ReadUserWithRetry>d__22.MoveNext() in D:\a\VisualStudio\VisualStudio\src\GitHub.Api\LoginManager.cs:line 335 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at GitHub.Api.LoginManager.<LoginViaOAuth>d__14.MoveNext() in D:\a\VisualStudio\VisualStudio\src\GitHub.Api\LoginManager.cs:line 158 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at GitHub.VisualStudio.ConnectionManager.<LogInViaOAuth>d__14.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at GitHub.ViewModels.Dialog.LoginTabViewModel.<LoginToHostViaOAuth>d__56.MoveNext() in D:\a\VisualStudio\VisualStudio\src\GitHub.App\ViewModels\Dialog\LoginTabViewModel.cs:line 173 {"message":"Requires authentication","documentation_url":"https://docs.github.com/rest/reference/users#get-the-authenticated-user"} 2020-08-15 22:31:05.818 [20420] EROR [05] GitHubServiceProvider Error loading GitHub.Services.IConnectionManager System.InvalidOperationException: Due to high risk of deadlock you cannot call GetService from a background thread in an AsyncPackage derived class. You should instead call GetServiceAsync (without calling Result or Wait on the resultant Task object) or switch to the UI thread with the JoinableTaskFactory.SwitchToMainThreadAsync method before calling GetService. at Microsoft.VisualStudio.Shell.AsyncPackage.GetService(Type serviceType) at Microsoft.VisualStudio.Shell.Package.System.IServiceProvider.GetService(Type serviceType) at GitHub.VisualStudio.GitHubServiceProvider.TryGetService(Type serviceType) 2020-08-15 22:34:32.192 [20420] EROR [01] LoginTabViewModel Error logging into '"https://github.com/"' as '' Octokit.AuthorizationException: Requires authentication at Octokit.Connection.HandleErrors(IResponse response) at Octokit.Connection.<RunRequest>d__58.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Octokit.Connection.<Run>d__571.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at GitHub.Api.LoginManager.d__23.MoveNext() in D:\a\VisualStudio\VisualStudio\src\GitHub.Api\LoginManager.cs:line 346
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at GitHub.Api.LoginManager.d__22.MoveNext() in D:\a\VisualStudio\VisualStudio\src\GitHub.Api\LoginManager.cs:line 335
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at GitHub.Api.LoginManager.d__14.MoveNext() in D:\a\VisualStudio\VisualStudio\src\GitHub.Api\LoginManager.cs:line 158
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at GitHub.VisualStudio.ConnectionManager.d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at GitHub.ViewModels.Dialog.LoginTabViewModel.d__56.MoveNext() in D:\a\VisualStudio\VisualStudio\src\GitHub.App\ViewModels\Dialog\LoginTabViewModel.cs:line 173
{"message":"Requires authentication","documentation_url":"https://docs.github.com/rest/reference/users#get-the-authenticated-user"}

@jcansdale
Copy link
Collaborator

@iozcelik @techduggu,

Are you by any chance using a VPN?

@iozcelik
Copy link
Author

@jcansdale I tried and result is same.

@jcansdale
Copy link
Collaborator

@iozcelik,

I tried and result is same.

You tried with and without a VPN?

@iozcelik
Copy link
Author

When I open this issue, I tried without Vpn. After you asked, I tried with it.

@jcansdale
Copy link
Collaborator

@iozcelik,

When I open this issue, I tried without Vpn. After you asked, I tried with it.

That's a shame. 😢

When the page fails to load:

image

Could you try replacing localhost with 127.0.0.1? Could you also try ping localhost and check that's it's pointing at 127.0.0.1?

Thanks!

@jcansdale
Copy link
Collaborator

Hi @iozcelik,

Another user was able to fix this by launching Visual Studio as Administrator before logging in, see #2550 (comment).

Could you give that a try? 🙏

@iozcelik
Copy link
Author

iozcelik commented Oct 5, 2020

@jcansdale I will try as soon as possible.

@avatar25
Copy link

It doesn't work for me as well. I tried to run VS19 as an administrator but it doesn't resolve. With/without VPN makes no difference either.

@jcansdale
Copy link
Collaborator

@avatar25 thanks for checking!

Do you know if you've used any apps that run on localhost successfully?

A quick check would to try using my TestDriven.NET extension:
https://testdriven.net/download_release.aspx?LicenceType=Personal

After installing the extension, you can right-click inside any method and Run Test(s). If this works, we'll have confirmed that a callback to localhost can work on your machine.

@dotnetgik
Copy link

I resolved issue by copying the link

https://github.com/login/oauth/authorize?client_id=a200baed193bb2088a6e&scope=user%2Crepo%2Cgist%2Cwrite%3Apublic_key%2Cread%3Aorg%2Cworkflow&state=710e9410-38be-4566-a024-36fe91e414ad

and opening it in Incognito Mode now i am able to login and load my repositories properly in the visual studio

@jcansdale
Copy link
Collaborator

@dotnetgik interesting, thanks! I wonder why Incognito Mode was required? 🤔

@KyuuzoT
Copy link

KyuuzoT commented Nov 24, 2020

I've faced the same problem with authorization as everyone above. So, I've tried to:

  1. Run VS2019 as administrator.
  2. Clean the .git-credentials
  3. Set my wireless connection as "private"
  4. Restart computer several times.
  5. Reinstall GitHub Extension several times.
  6. Reinstall entire VS2019 several times.
  7. Copy connection link to Chrome with incognito mode.
  8. Copy connection link to Firefox and Edge.

Also, I haven't seen if somebody mentioned before but I see in TeamExplorer my local repositories (not all of them, just from one specific folder - C:\Users\User\Source\Repos). However I can not look through or work with any of my remote projects.

So, what should I do to make this extension work?

@KyuuzoT
Copy link

KyuuzoT commented Nov 24, 2020

@KyuuzoT I've just tried to connect via VPN - no result.
Then, I've tried to copy authorization link to TOR Browser (yeah, I know it's Firefox) - A window for entering an email and password appeared, after entering my credentials I've received a verification code. But after entering the code I've got the same "localhost refused to connect"-problem.

@SenzoNgele
Copy link

Lool after I struggled for years.. I have found a Solution to This
The course is. First I use my google chrome which I saved my Github account with.
So my VS was taking me to Microsoft Edge and get the button disabled.

All you have to do is to change you Default browser on your machine to the one u have signed is with on github

@jcansdale
Copy link
Collaborator

Hi @KyuuzoT,

I'm sorry you've had such a hard time getting this to work!

There was another suggestion here #2527 (comment).

  1. Put this into Chrome address bar: chrome://net-internals/#hsts
  2. Then go to the bottom and delete localhost from the Delete domain security policies

Might that the the issue?

@KyuuzoT
Copy link

KyuuzoT commented Nov 26, 2020

Hi @KyuuzoT,

I'm sorry you've had such a hard time getting this to work!

There was another suggestion here #2527 (comment).

  1. Put this into Chrome address bar: chrome://net-internals/#hsts
  2. Then go to the bottom and delete localhost from the Delete domain security policies

Might that the the issue?

Hi @jcansdale

Yeah, I forgot to mention that I've already done this and still have no result.

Also, I've been testing extension in it's current state on my computer for some time and found out that I could make commits, create branches, pull & fetch etc if I'll find project that fits my remote repo and open it from VS2019 directly. Also I can clone my remote repos via direct link instead of opening them, which is not conveniently, because I do not need several versions of one project in different folders on my local PC (I'm using version management system for this particular reason, right?). So I have functionality of this extension despite the fact that I still got the "unconnected" message and I still can not see any of my remote repos in VS2019 (I see only list of my local repos). What does it mean and how it works this way I have no idea at all.

@iozcelik
Copy link
Author

After update to lastest version the problem is fix for me. Now I can login.

@KyuuzoT
Copy link

KyuuzoT commented Nov 26, 2020

@iozcelik "the latest version" of what? VS or Git extension?

@iozcelik
Copy link
Author

@KyuuzoT "Visual Studio 16.8.2" but now I have lots of different problem :)

@KyuuzoT
Copy link

KyuuzoT commented Nov 26, 2020

@iozcelik Well, I'm facing this problem while being on VS 16.8.2

@jcansdale
Copy link
Collaborator

jcansdale commented Nov 26, 2020

Hi @KyuuzoT (and anyone else having auth issues),

I've just added a new subcommand set-token to a .NET Core tool called ghvs. This tool contains various GitHub and Visual Studio related subcommands. You can find the PR here:
jcansdale/ghvs#44

Please can you try the following:

  1. Create a PAT with the following scopes: "user", "repo", "gist", "write:public_key", "read:org", "workflow"
    You can use this link https://github.com/settings/tokens
    image
  2. Install the ghvs tool
    dotnet tool install -g ghvs --version 1.0.113-g022796defc
  3. Set the GitHub for Visual Studio token
    ghvs set-token --secret-store ghfvs <PAT>
  4. Open Visual Studio and File > Open > Open from GitHub...

If everything went to plan, a list of repositories should appear. 🤞

Please let me know how you get on!

@KyuuzoT
Copy link

KyuuzoT commented Nov 26, 2020

Hi @jcansdale

I've got this message:
Unrecognized command or argument 'set-token'

Did you mean this?
    access-token

on step №3. And I don't see neither a command nor the option 'set-token' in ghvs --help.

@jcansdale
Copy link
Collaborator

@KyuuzoT,

Could you check that you installed version 1.0.113-g022796defc (which is the version from jcansdale/ghvs#44)?

$ dotnet tool install -g ghvs --version 1.0.113-g022796defc
You can invoke the tool using the following command: ghvs
Tool 'ghvs' (version '1.0.113-g022796defc') was successfully installed.

The help page should look like this:

$ ghvs --help

Usage: ghvs [options] [command]

Options:
  --help          Show help information
  --host          The host URL
  --access-token  The access token to use
  --secret-store  The secret store to use (Git or GHfVS)

Commands:
  branch          Show information about the current branch
  install         Install 'x-github-client' protocol handler
  issues          Show issues
  login           Login using GitHub Credential Manager
  logout          Logout using GitHub Credential Manager
  open            Open a file or folder in Visual Studio
  open-url        Open a GitHub URL in Visual Studio
  orgs            Show visible organizations (requires 'read:org' scope)
  pulls           Show pull requests
  repos           List repositories
  set-token       Set credentials with a personal access token
  uninstall       Uninstall 'x-github-client' protocol handler
  upstream        Show information about the upstream repository
  viewer          Show viewer information

Run 'ghvs [command] --help' for more information about a command.

@V4A001
Copy link

V4A001 commented Dec 2, 2020

@jcansdale for me the fix with ghvs works. Thank you! With azure az login I have same issue, I use az login --use-device-code instead.

@chrisdyckgeorgian
Copy link

chrisdyckgeorgian commented Dec 8, 2020

I am having the same challenge. The GitHub link shows "This site can't be reached"

Here is my output from ghvs

G:>dotnet tool install -g ghvs --version 1.0.113-g022796defc

Welcome to .NET 5.0!

SDK Version: 5.0.101

Telemetry

The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry


Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only).
Learn about HTTPS: https://aka.ms/dotnet-https

Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli

You can invoke the tool using the following command: ghvs
Tool 'ghvs' (version '1.0.113-g022796defc') was successfully installed.

G:>ghvs set-token --secret-store ghfvs 7679c0d45d2297f4e0b4ec36c213fd017a58827f

Here is a screen shot from the VS Create Git
image

@jcansdale
Copy link
Collaborator

Hi @chrisdyckgeorgian,

This dialog is actually part of recent Visual Studio versions and isn't installed with GitHub for Visual Studio.

Could you try using the File > Open > Open from GitHub ... command and see if you can login/clone a repository? (this functionality is part of GitHub for Visual Studio)

@rmatejka
Copy link

rmatejka commented Mar 16, 2021

I'm having the same problem in VS 2019 Preview Version 16.10.0 Preview 1.0. I've tried all of the suggestions and still no go. The logs contain this:

2021-03-15 17:47:01.507 [04260] INFO [67] GitHubPackage Initializing GitHub Extension v2.11.102.28613 in Microsoft Visual Studio 2019 Preview (16.10.31025.218)
2021-03-15 18:23:49.749 [13012] INFO [14] GitHubPackage Initializing GitHub Extension v2.11.102.28613 in Microsoft Visual Studio 2019 Preview (16.10.31025.218)
2021-03-15 18:24:02.155 [13012] EROR [21] GitHubServiceProvider Error loading GitHub.Services.IConnectionManager
System.InvalidOperationException: Due to high risk of deadlock you cannot call GetService from a background thread in an AsyncPackage derived class. You should instead call GetServiceAsync (without calling Result or Wait on the resultant Task object) or switch to the UI thread with the JoinableTaskFactory.SwitchToMainThreadAsync method before calling GetService.
at Microsoft.VisualStudio.Shell.AsyncPackage.GetService(Type serviceType)
at Microsoft.VisualStudio.Shell.Package.System.IServiceProvider.GetService(Type serviceType)
at GitHub.VisualStudio.GitHubServiceProvider.TryGetService(Type serviceType)

Prior to switching to preview, I just used the older version of the extension but now that's no longer possible in preview so I need a solution. What worked once was this #2521 (comment) but now that is no longer helping either.

Any suggestions?

@jcansdale
Copy link
Collaborator

@rmatejka I'm interested to know what happens if you uninstall the extension and try Visual Studio's built-in GitHub integration. See #2521 (comment) for instructions.

Please let me know how you get on!

@legistek
Copy link

This has been opened since June 2020 and still isn't fixed? What a joke.

@rmatejka
Copy link

@rmatejka I'm interested to know what happens if you uninstall the extension and try Visual Studio's built-in GitHub integration. See #2521 (comment) for instructions.

Please let me know how you get on!

The same issue just different port:
http://localhost:47120/?code=16a457fd323681d0dc61&state=fea7bdc119a44d77be40f99c4523b9e6

@legistek
Copy link

legistek commented Apr 2, 2021

I finally determined what was causing this for me and how to fix it.

I frequently run my application server on localhost. My application is hard coded to send the Strict-Transport-Security header even in debug mode (which it probably need not be). This causes Chrome to refuse to access the domain (i.e. localhost) except through SSL. It remembers this for the future, even when it's a different application on localhost. Thus the github integration hook, which apparently only uses HTTP, gets rejected by Chrome.

Easy solution - clear your browser history and cache (you don't have to clear cookies). And that's it.

Correct solution for Microsoft - run the hook through HTTPS.

@raj-oo8
Copy link

raj-oo8 commented Apr 20, 2021

I finally determined what was causing this for me and how to fix it.

I frequently run my application server on localhost. My application is hard coded to send the Strict-Transport-Security header even in debug mode (which it probably need not be). This causes Chrome to refuse to access the domain (i.e. localhost) except through SSL. It remembers this for the future, even when it's a different application on localhost. Thus the github integration hook, which apparently only uses HTTP, gets rejected by Chrome.

Easy solution - clear your browser history and cache (you don't have to clear cookies). And that's it.

Correct solution for Microsoft - run the hook through HTTPS.

Thanks a ton, this works for me finally! BTW just clearing browser cache works, no need to clear history

@MutazShamsan
Copy link

Hi @KyuuzoT,

I'm sorry you've had such a hard time getting this to work!

There was another suggestion here #2527 (comment).

  1. Put this into Chrome address bar: chrome://net-internals/#hsts
  2. Then go to the bottom and delete localhost from the Delete domain security policies

Might that the the issue?

This works for me

@c-l-i-n-t
Copy link

Works in Edge also.

edge://net-internals/#hsts

@mightysabean
Copy link

What worked for me was deleting all my cookies and browsing history (From Microsoft Edge Browser)

@AnkitSaraf30553
Copy link

Note: Adding this comment here to provide more information (as already added into #2509 )

Hi Team,

Even I am facing this issue with GitHub extension with Visual Studio 2019. I have tried the above workarounds (uninstalling/reverting to previous version etc.) but no luck.

I am able to sign-in successfully to GitHub on my browser but through extension, when I click on 'Sign in with your browser' option, it opens the browser with the below URL and it just keeps loading: https://github.com/login/oauth/authorize?client_id=a200baed193bb2088a6e&scope=user%2Crepo%2Cgist%2Cwrite%3Apublic_key%2Cread%3Aorg%2Cworkflow&state=cd3677b8-bf82-4d2d-80c2-71fb3ed7cb63

Below is the error captured from Github Extension log:

2020-08-15 22:29:05.832 [20420] INFO [58] GitHubPackage Initializing GitHub Extension v2.11.104.25275 in Microsoft Visual Studio 2019 (16.6.30114.105)
2020-08-15 22:29:23.860 [20420] EROR [01] LoginTabViewModel Error logging into '"https://github.com/"' as ''
Octokit.AuthorizationException: Requires authentication
at Octokit.Connection.HandleErrors(IResponse response)
at Octokit.Connection.d__58.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Octokit.Connection.d__571.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at GitHub.Api.LoginManager.<GetUserAndCheckScopes>d__23.MoveNext() in D:\a\VisualStudio\VisualStudio\src\GitHub.Api\LoginManager.cs:line 346 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at GitHub.Api.LoginManager.<ReadUserWithRetry>d__22.MoveNext() in D:\a\VisualStudio\VisualStudio\src\GitHub.Api\LoginManager.cs:line 335 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at GitHub.Api.LoginManager.<LoginViaOAuth>d__14.MoveNext() in D:\a\VisualStudio\VisualStudio\src\GitHub.Api\LoginManager.cs:line 158 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at GitHub.VisualStudio.ConnectionManager.<LogInViaOAuth>d__14.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at GitHub.ViewModels.Dialog.LoginTabViewModel.<LoginToHostViaOAuth>d__56.MoveNext() in D:\a\VisualStudio\VisualStudio\src\GitHub.App\ViewModels\Dialog\LoginTabViewModel.cs:line 173 {"message":"Requires authentication","documentation_url":"https://docs.github.com/rest/reference/users#get-the-authenticated-user"} 2020-08-15 22:31:05.818 [20420] EROR [05] GitHubServiceProvider Error loading GitHub.Services.IConnectionManager System.InvalidOperationException: Due to high risk of deadlock you cannot call GetService from a background thread in an AsyncPackage derived class. You should instead call GetServiceAsync (without calling Result or Wait on the resultant Task object) or switch to the UI thread with the JoinableTaskFactory.SwitchToMainThreadAsync method before calling GetService. at Microsoft.VisualStudio.Shell.AsyncPackage.GetService(Type serviceType) at Microsoft.VisualStudio.Shell.Package.System.IServiceProvider.GetService(Type serviceType) at GitHub.VisualStudio.GitHubServiceProvider.TryGetService(Type serviceType) 2020-08-15 22:34:32.192 [20420] EROR [01] LoginTabViewModel Error logging into '"https://github.com/"' as '' Octokit.AuthorizationException: Requires authentication at Octokit.Connection.HandleErrors(IResponse response) at Octokit.Connection.<RunRequest>d__58.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Octokit.Connection.<Run>d__571.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at GitHub.Api.LoginManager.d__23.MoveNext() in D:\a\VisualStudio\VisualStudio\src\GitHub.Api\LoginManager.cs:line 346
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at GitHub.Api.LoginManager.d__22.MoveNext() in D:\a\VisualStudio\VisualStudio\src\GitHub.Api\LoginManager.cs:line 335
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at GitHub.Api.LoginManager.d__14.MoveNext() in D:\a\VisualStudio\VisualStudio\src\GitHub.Api\LoginManager.cs:line 158
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at GitHub.VisualStudio.ConnectionManager.d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at GitHub.ViewModels.Dialog.LoginTabViewModel.d__56.MoveNext() in D:\a\VisualStudio\VisualStudio\src\GitHub.App\ViewModels\Dialog\LoginTabViewModel.cs:line 173
{"message":"Requires authentication","documentation_url":"https://docs.github.com/rest/reference/users#get-the-authenticated-user"}

You can try 3 things for this issue

  1. try with Administrator mode of visual studio.
  2. download latest git credentials manager
  3. add //.vs//DesignTimeBuild/.dtbcache.v2 to git ignore

@AnkitSaraf30553
Copy link

You can try 3 things for this issue

try with Administrator mode of visual studio.
download latest git credentials manager
add //.vs//DesignTimeBuild/.dtbcache.v2 to git ignore

@noesisterna
Copy link

Lool después de haber luchado durante años ... He encontrado una solución a esto El curso es. Primero uso mi Google Chrome con el que guardé mi cuenta de Github. Entonces, mi VS me estaba llevando a Microsoft Edge y desactivaba el botón.

Todo lo que tiene que hacer es cambiar su navegador predeterminado en su máquina al que ha firmado en github

Gracias!!! soluciones mi problema!!

@GiangNguyenDev
Copy link

I finally determined what was causing this for me and how to fix it.

I frequently run my application server on localhost. My application is hard coded to send the Strict-Transport-Security header even in debug mode (which it probably need not be). This causes Chrome to refuse to access the domain (i.e. localhost) except through SSL. It remembers this for the future, even when it's a different application on localhost. Thus the github integration hook, which apparently only uses HTTP, gets rejected by Chrome.

Easy solution - clear your browser history and cache (you don't have to clear cookies). And that's it.

Correct solution for Microsoft - run the hook through HTTPS.

Thank you very much. I got the issue finally resolved with your suggestion. Well done!

@mlhein
Copy link

mlhein commented Apr 5, 2022

I finally determined what was causing this for me and how to fix it.
I frequently run my application server on localhost. My application is hard coded to send the Strict-Transport-Security header even in debug mode (which it probably need not be). This causes Chrome to refuse to access the domain (i.e. localhost) except through SSL. It remembers this for the future, even when it's a different application on localhost. Thus the github integration hook, which apparently only uses HTTP, gets rejected by Chrome.
Easy solution - clear your browser history and cache (you don't have to clear cookies). And that's it.
Correct solution for Microsoft - run the hook through HTTPS.

Thank you very much. I got the issue finally resolved with your suggestion. Well done!

Thank you, this resolved the issue.

@nehasapra21
Copy link

Hi @KyuuzoT,

I'm sorry you've had such a hard time getting this to work!

There was another suggestion here #2527 (comment).

  1. Put this into Chrome address bar: chrome://net-internals/#hsts
  2. Then go to the bottom and delete localhost from the Delete domain security policies

Might that the the issue?

Thanks this solution resolve my problem

@AbstractionsAs
Copy link

None of the proposed solutions seem to solve the problem for me.
It hangs attempting to reach localhost - it doesn't seem to to listening for incoming requests.

@TechGeneralista
Copy link

I never had a problem logging in, now I have. It was so much that I had to delete the chrome browsing history. solved

@Premier-Solutions
Copy link

The issue that I was facing was that github was redirecting me to localhost without adding the port number.
http://localhost/?browser_session_id=96cee3401f9a78b6f307eb0819606d4f80e21988a8a945fb6d3b9b74e032de8e&code=90255ccef1a34eac35cb&state=189a50d1-b1ae-405d-8b46-ecf54e3528a1

I just added the port number as mentioned in ttaylor29 (42549) comment and it worked fine then.

@Alex8695
Copy link

The issue that I was facing was that github was redirecting me to localhost without adding the port number. http://localhost/?browser_session_id=96cee3401f9a78b6f307eb0819606d4f80e21988a8a945fb6d3b9b74e032de8e&code=90255ccef1a34eac35cb&state=189a50d1-b1ae-405d-8b46-ecf54e3528a1

I just added the port number as mentioned in ttaylor29 (42549) comment and it worked fine then.

I can say that this fixed my issue as well.

changed localhost to localhost:42549 and it connected without an further issue.

@asmak9
Copy link

asmak9 commented Oct 18, 2022

The issue that I was facing was that github was redirecting me to localhost without adding the port number. http://localhost/?browser_session_id=96cee3401f9a78b6f307eb0819606d4f80e21988a8a945fb6d3b9b74e032de8e&code=90255ccef1a34eac35cb&state=189a50d1-b1ae-405d-8b46-ecf54e3528a1
I just added the port number as mentioned in ttaylor29 (42549) comment and it worked fine then.

I can say that this fixed my issue as well.

changed localhost to localhost:42549 and it connected without an further issue.

This fix my issue, but, how can we map the port to automatically open in GitHub sign-In with browser for visual studio?

@DevMatSolutions
Copy link

The issue that I was facing was that github was redirecting me to localhost without adding the port number. http://localhost/?browser_session_id=96cee3401f9a78b6f307eb0819606d4f80e21988a8a945fb6d3b9b74e032de8e&code=90255ccef1a34eac35cb&state=189a50d1-b1ae-405d-8b46-ecf54e3528a1
I just added the port number as mentioned in ttaylor29 (42549) comment and it worked fine then.

I can say that this fixed my issue as well.

changed localhost to localhost:42549 and it connected without an further issue.

worked for me also

@santoshasc
Copy link

Fixed 42549 my issue THnks

@3PR
Copy link

3PR commented Oct 21, 2022

I found a workaround that worked for me. (update: it just looked like it authorized but did not)

from GitHub website repository : Open with visual studio.

A popup on visual studio should appear to login.

Select the option to sign in with code.

Enter the code into the webpage that opens and authorize Visual Studio.

Never mind it just looked like it worked. the above comment solution worked (adding port 42549 to localhost)

@LePoeTe
Copy link

LePoeTe commented Oct 23, 2022

The issue that I was facing was that github was redirecting me to localhost without adding the port number. http://localhost/?browser_session_id=96cee3401f9a78b6f307eb0819606d4f80e21988a8a945fb6d3b9b74e032de8e&code=90255ccef1a34eac35cb&state=189a50d1-b1ae-405d-8b46-ecf54e3528a1

I just added the port number as mentioned in ttaylor29 (42549) comment and it worked fine then.

This is fixed my issue.
Thanks

@camaro322hp
Copy link

The issue that I was facing was that github was redirecting me to localhost without adding the port number. http://localhost/?browser_session_id=96cee3401f9a78b6f307eb0819606d4f80e21988a8a945fb6d3b9b74e032de8e&code=90255ccef1a34eac35cb&state=189a50d1-b1ae-405d-8b46-ecf54e3528a1

I just added the port number as mentioned in ttaylor29 (42549) comment and it worked fine then.

Thank you - worked for me also.

@wk3d
Copy link

wk3d commented Mar 14, 2023

This happened to me as well. I tried different things from this and other threads and nothing worked. Firefox was the only browser taking me to GitHub login so I changed my default browser to Firefox so it would open from VS. It worked and logged me in. Maybe helpful to try the link in different browsers to find which one actually opens the site.

@GusGusGusGus
Copy link

GusGusGusGus commented Apr 4, 2023

In my case I had an issue with hsts as edge and chrome were trying ot use https to redirect to localhost. I just went to edge://net-internals/#hsts within edge and under Delete domain security policies I typed localhost. Then I retried logging in with VS and the authentication was successful.

@remustechco
Copy link

In my case I had an issue with hsts as edge and chrome were trying ot use https to redirect to localhost. I just went to edge://net-internals/#hsts within edge and under Delete domain security policies I typed localhost. Then I retried logging in with VS and the authentication was successful.

This is the solution that works for me too.

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

No branches or pull requests