microsoft / artifacts-credprovider

The Azure Artifacts Credential Provider enables dotnet, NuGet.exe, and MSBuild to interactively acquire credentials for Azure Artifacts feeds.
MIT License
759 stars 707 forks source link

Persist credentials independent of session cache #402

Closed m-soltani closed 1 year ago

m-soltani commented 1 year ago

I am on mac using pwsh core 7 and after when I try to register an azure artifact feed as a private powershell repository as described in the doc here: register private feed. This works perfectly for the first time I want to register the repository, but when I close the session and create a new session again, it asks me for a device authentication flow every time I want to run a command related to the registered repository.

Is there a way to cache the credentials independent of the session?

JohnSchmeichel commented 1 year ago

I would expect the credential provider's token cache to be working here.. suspect that PS is passing -IsRetry in these cases. Can you enable MSAL and see if it helps here? There's token caches enabled by default for MSAL (and work much better).

Ensure this gets enabled for all sessions:

export NUGET_CREDENTIALPROVIDER_MSAL_ENABLED=true
m-soltani commented 1 year ago

This did not worked in my case. However, setting the environment variable VSS_NUGET_EXTERNAL_FEED_ENDPOINTS in pwsh user's profile did the job.