-
Notifications
You must be signed in to change notification settings - Fork 255
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
nuget command line ignores credentials saved by Visual studio #10710
Comments
If you decide to go with alternative 2 - then it's possible to load credential cache using code like this:
Attached files are stripped down versions from https://github.com/microsoft/artifacts-credprovider. And credentials can be returned like this:
After which authentication works out of box. |
If you have influence on how much time PAT will be valid (E.g. set |
Thanks a lot for you detailed analysis, @tapika nuget.exe works with .NET Framework ; so, it will use .NET Framework Authentication plugin. The Azure Artifacts Credential plugin is maintained by a team external to NuGet. I will close this issue and repost in microsoft/artifacts-credprovider. Any questions, let us know. |
Are you sure .net core 2 theoretically goes into direction - less UI, more portable direction - would work also on linux, mac, android. with .net 5 it's possible to get more UI and more portable. |
Tested with nuget 5.8.0.6930, and 5.9.0.7134.
When running "nuget.exe restore solution.sln" command - nuget does not use Visual Studio credentials, and does not prompt to enter login and password.
First provider which gets executed is
MsalDeviceCodeFlowBearerTokenProvider
.Text banner looks like this:
Brief analysis of https://github.com/microsoft/artifacts-credprovider code and couple of debug sessions revealed to me what was the problem.
There exists two different compilations of credprovider - namely .net core's without user interface, and .net framework (
NETFRAMEWORK
define macro enabled) with user interface.By default if you install credential provider using command line like
installcredprovider.ps1
it will download .net core credential provider, which is without user interface.
If you however use
-AddNetfx
parameter at the end - it will download .net framework based credential provider, which in a turn can display login and password prompt to azure and avoid that ugly device based authentication.I guess for nuget there are two strategies which can be used.
VstsCredentialProvider
class)(E.g. powershell script like this could be used if necessary: chocolatey/choco#1721 (comment))
nuget restore already have
-NonInteractive
which can be used to suppress UI prompt if necessary.%localappdata%\MicrosoftCredentialProvider\SessionTokenCache.dat
file directly and authorizes against azure if personal access token is not expired.I by myself would prefer to have 1 implemented and using
-NonInteractive
it would be possible to suppress login dialog.Device code bearer token provider authorizes nuget restore for 4 hours - which is quite small amount of time for developer.
(Yesterday it was working - what? - again to log in ?)
If it continues to authorize for 4 hours, then I would prefer to remove it or obsolete it.
In link above I've managed to suppress by setting timeout limit environment variable - but this maybe not good from nuget console output perspective.
The text was updated successfully, but these errors were encountered: