github / VisualStudio

GitHub Extension for Visual Studio
https://visualstudio.github.com
MIT License
2.38k stars 1.2k forks source link

unable to connect to GitHub using visual studio 2019 #2527

Open mohan023 opened 4 years ago

mohan023 commented 4 years ago

Below is what I got in logs.

Octokit.AuthorizationException: Must authenticate to access this API. at Octokit.Connection.HandleErrors(IResponse response) at Octokit.Connection.d58.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.d571.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.d18.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.d13.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.d13.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.d13.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__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

techduggu commented 4 years ago

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.d58.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.d571.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.d23.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.d22.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.d14.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.d14.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"}

YounesCheikh commented 4 years ago

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

jcansdale commented 4 years ago

@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?

mohan023 commented 4 years ago

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

jcansdale commented 4 years ago

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

jcansdale commented 4 years ago

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!

BHinrichs1966 commented 4 years ago

@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.

jcansdale commented 4 years ago

Hi @BHinrichs1966,

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

BHinrichs1966 commented 4 years ago

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

[cid:image001.png@01D6B1C7.46C8C7A0]

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:notifications@github.com] Sent: Tuesday, November 3, 2020 8:40 AM To: github/VisualStudio VisualStudio@noreply.github.com Cc: Hinrichs, Brad (Lincoln) Brad.Hinrichs@fiserv.com; Mention mention@noreply.github.com 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=.

jcansdale commented 4 years ago

@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!

mohan023 commented 4 years ago

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

ttaylor29 commented 4 years ago

@mohan023 I'm seeing this again :/

jcansdale commented 4 years ago

@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

ttaylor29 commented 4 years ago

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

jcansdale commented 4 years ago

@ttaylor29,

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

ttaylor29 commented 4 years ago

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

ttaylor29 commented 4 years ago

@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 commented 4 years ago

@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 commented 4 years ago

@jcansdale It still failed :-(

image

image

Then this shows up:

image

ttaylor29 commented 4 years ago

@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

jcansdale commented 4 years ago

@ttaylor29 I'm glad you figured it out!

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

WagaoPRC commented 3 years ago

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.

mightysabean commented 3 years ago

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

huytruongtdh commented 2 years ago

@jcansdale @mohan023

I might have found it.

put this into Chrome address bar:

chrome://net-internals/#hsts

This works for me. Thanks