VisualStudio icon indicating copy to clipboard operation
VisualStudio copied to clipboard

unable to connect to GitHub using visual studio 2019

Open mohan023 opened this issue 4 years ago • 24 comments

Below is what I got in logs.

Octokit.AuthorizationException: Must authenticate to access this API. 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 Octokit.ApiConnection.<Put>d__261.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.<CreateAndDeleteExistingApplicationAuthorization>d__18.MoveNext() in D:\a\VisualStudio\VisualStudio\src\GitHub.Api\LoginManager.cs:line 220 --- 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.<Login>d__13.MoveNext() in D:\a\VisualStudio\VisualStudio\src\GitHub.Api\LoginManager.cs:line 102 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at GitHub.Api.LoginManager.<Login>d__13.MoveNext() in D:\a\VisualStudio\VisualStudio\src\GitHub.Api\LoginManager.cs:line 125 --- 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.<LogIn>d__13.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.<LogInToHost>d__55.MoveNext() in D:\a\VisualStudio\VisualStudio\src\GitHub.App\ViewModels\Dialog\LoginTabViewModel.cs:line 159 {"message":"Must authenticate to access this API.","documentation_url":"https://developer.github.com/enterprise/2.19/v3"}

image image

mohan023 avatar Jul 01 '20 13:07 mohan023

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.<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.<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.<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"}

techduggu avatar Aug 15 '20 17:08 techduggu

I have the same problem,

Logs here extension.log

Solution worked for me 👍

I solved the problem by connecting in Github : Profile/Settings/Developer settings/Personal access tokens Then revoke all from token access list. Direct url

YounesCheikh avatar Sep 06 '20 11:09 YounesCheikh

@mohan023 @techduggu,

@cyounes was able to resolve this by opening Visual Studio as Administrator before logging in, see https://github.com/github/VisualStudio/issues/2550#issuecomment-703280956

Any chance you could give this a try?

jcansdale avatar Oct 05 '20 17:10 jcansdale

I'm still facing this issue. Tried most of the suggestions mentioned here.

mohan023 avatar Oct 06 '20 04:10 mohan023

@mohan023, I'm sorry this didn't fix it. Thanks for trying!

jcansdale avatar Oct 06 '20 11:10 jcansdale

Hi @mohan023 (and @techduggu),

I think the issue you've been seeing might be this #2560 (reported by @osmanager). I've opened a PR that I hope will resolve the problem here #2562.

Could you try installing the artifact from this build: https://github.com/github/VisualStudio/pull/2562/checks?check_run_id=1309274757

You can find it here: https://github.com/github/VisualStudio/suites/1400504505/artifacts/23266202

After opening and installing the VSIX, can you let me know if it works any better? Any help confirming this fix would be much appreciated!

jcansdale avatar Oct 26 '20 14:10 jcansdale

@jcansdale I have the same issue as Mohan023 and techduggu. I tried using the link you provided, https://github.com/github/VisualStudio/suites/1400504505/artifacts/23266202 but I receive a 404 error.

BHinrichs1966 avatar Oct 26 '20 19:10 BHinrichs1966

Hi @BHinrichs1966,

Could you try installing the artifact from this link? https://github.com/github/VisualStudio/runs/1343191255?check_suite_focus=true

jcansdale avatar Nov 03 '20 14:11 jcansdale

I downloaded the new extension. When I attempt to install it, it fails.

[cid:[email protected]]

I am attaching the .log

I am able to install the “production” version of this extension using the VS extension manager. But, not able to install this local copy. My company does have restrictions on our machines. I am not an administrator on my own machine. Could that be causing this to fail?

Brad Hinrichs Data Architect, Advisory Bank Solutions Office: 402-423-2682 x. 3966

Fiserv Register Today! | Forum 2020 Virtual Experiencehttps://www.fiserv.com/en/forum-2020.html?utm_medium=link&utm_campaign=forum2020&utm_source=fiservsignature&utm_content=text_save_the_date Fiservhttps://www.fiserv.com/index.aspx | Join Our Teamhttps://www.careers.fiserv.com/?utm_source=outlook&utm_medium=email&utm_campaign=signature | Twitterhttps://twitter.com/fiserv | LinkedInhttps://www.linkedin.com/company/fiserv/ | Facebookhttps://www.facebook.com/Fiserv/ FORTUNE Magazine World's Most Admired Companies® 2014 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 © 2019 Fiserv, Inc. or its affiliates. Fiserv is a registered trademark of Fiserv, Inc. Privacy Policyhttp://fiserv.com/about/privacypolicy.aspx

From: Jamie Cansdale [mailto:[email protected]] Sent: Tuesday, November 3, 2020 8:40 AM To: github/VisualStudio [email protected] Cc: Hinrichs, Brad (Lincoln) [email protected]; Mention [email protected] Subject: Re: [github/VisualStudio] unable to connect to GitHub using visual studio 2019 (#2527)

⚠ EXTERNAL MESSAGE – Think Before You Click

Hi @BHinrichs1966https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_BHinrichs1966&d=DwMCaQ&c=rE3mhBYFJfJGqQ7WI0-DPw&r=RC4v873OWPHaybHpbiRBtSxju4MLORmRToKb-DY5204&m=hTuSl72717zcbsE6wHcEgeS2xBDR3ZsIzfy2Hghsi40&s=HA3I43cjpbgbkqbWhCu2J0ym8HsMXtwN2jah6p32AVI&e=,

Could you try installing the artifact from this link? https://github.com/github/VisualStudio/runs/1343191255?check_suite_focus=truehttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_github_VisualStudio_runs_1343191255-3Fcheck-5Fsuite-5Ffocus-3Dtrue&d=DwMCaQ&c=rE3mhBYFJfJGqQ7WI0-DPw&r=RC4v873OWPHaybHpbiRBtSxju4MLORmRToKb-DY5204&m=hTuSl72717zcbsE6wHcEgeS2xBDR3ZsIzfy2Hghsi40&s=qehlUdiX15PPrH9esDjh3NnitVUK2U_aXoL46d5521U&e=

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_github_VisualStudio_issues_2527-23issuecomment-2D721155993&d=DwMCaQ&c=rE3mhBYFJfJGqQ7WI0-DPw&r=RC4v873OWPHaybHpbiRBtSxju4MLORmRToKb-DY5204&m=hTuSl72717zcbsE6wHcEgeS2xBDR3ZsIzfy2Hghsi40&s=wdwrD0cNvG9zAJ6-68Mr_Bvo3CnmNBIit1rh8LfcT6k&e=, or unsubscribehttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_ARQXTOGN7GQBOS4HCPPSX7LSOAI3ZANCNFSM4ONOEW5Q&d=DwMCaQ&c=rE3mhBYFJfJGqQ7WI0-DPw&r=RC4v873OWPHaybHpbiRBtSxju4MLORmRToKb-DY5204&m=hTuSl72717zcbsE6wHcEgeS2xBDR3ZsIzfy2Hghsi40&s=4emW2gJhHoTRk9lSNap24OA4dSzPvki6sknZEMR5RC0&e=.

BHinrichs1966 avatar Nov 03 '20 15:11 BHinrichs1966

@BHinrichs1966,

I am able to install the “production” version of this extension using the VS extension manager. But, not able to install this local copy. My company does have restrictions on our machines. I am not an administrator on my own machine. Could that be causing this to fail?

Yes, that could be causing this to fail. I'll let you know when this fix has been confirmed and a new version has been pushed to production!

jcansdale avatar Nov 03 '20 16:11 jcansdale

Do we have anyone who is not facing this issue anymore?

mohan023 avatar Nov 11 '20 15:11 mohan023

@mohan023 I'm seeing this again :/

ttaylor29 avatar Nov 18 '20 05:11 ttaylor29

@mohan023, @ttaylor29,

Any chance you could try the VSIX artifact from this build? https://github.com/github/VisualStudio/pull/2562/checks?check_run_id=1343191255

jcansdale avatar Nov 18 '20 12:11 jcansdale

@jcansdale Will this work if I just want normal GitHub and not the GitHub Enterprise Server?

ttaylor29 avatar Nov 18 '20 13:11 ttaylor29

@ttaylor29,

If there is an HTTP proxy between you and GitHub, it could make a difference. I'm interested to find out!

jcansdale avatar Nov 18 '20 14:11 jcansdale

@jcansdale I'll try this in a bit at lunch if I can!

ttaylor29 avatar Nov 18 '20 15:11 ttaylor29

@jcansdale How do I implement this?

Any chance you could try the VSIX artifact from this build? https://github.com/github/VisualStudio/pull/2562/checks?check_run_id=1343191255

FYI, I just tried it again with Chrome and it fails ; FireFox still works on my work laptop.

ttaylor29 avatar Nov 19 '20 02:11 ttaylor29

@jcansdale How do I implement this?

Any chance you could try the VSIX artifact from this build? https://github.com/github/VisualStudio/pull/2562/checks?check_run_id=1343191255

FYI, I just tried it again with Chrome and it fails ; FireFox still works on my work laptop.

Never mind, I found the artifact folder with the GitHub.VisualStudio.vsix

ttaylor29 avatar Nov 19 '20 02:11 ttaylor29

@jcansdale It still failed :-(

  • I go to sign in via this:

image

  • Then I get this to show up

image

Then this shows up:

image

ttaylor29 avatar Nov 19 '20 02:11 ttaylor29

@jcansdale @mohan023

I might have found it.

put this into Chrome address bar:

chrome://net-internals/#hsts

Then go to the bottom and delete localhost from the Delete domain security policies

Then try to sign into GitHub via VS2019 and it worked!!!

Chrome and Edge are chromium underneath the hood, so that is why it is happening on both!

I think my work puts these settings on from the group policy. I have to do this with using IIS local to run my web application sometimes.

image

ttaylor29 avatar Nov 19 '20 02:11 ttaylor29

@ttaylor29 I'm glad you figured it out!

I wonder if it treats localhost the same as 127.0.0.1? 🤔

jcansdale avatar Nov 20 '20 17:11 jcansdale

chrome://net-internals/#hsts

This method work for me. i have no problem with webapp then using localhost too. Maybe beacause adress is set for VS.

WagaoPRC avatar May 12 '21 12:05 WagaoPRC

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

mightysabean avatar Jun 17 '21 10:06 mightysabean

@jcansdale @mohan023

I might have found it.

put this into Chrome address bar:

chrome://net-internals/#hsts

This works for me. Thanks

huytruongtdh avatar Mar 17 '22 03:03 huytruongtdh