void InitializeDefaultCredentialProvider()
        {
            var credentialService = new CredentialService(
                GetCredentialProviders(),
                nonInteractive: false);

            HttpHandlerResourceV3Extensions.InitializeHttpHandlerResourceV3(credentialService);
        }
Ejemplo n.º 2
0
        public static ICredentialService CreateNonInteractiveCredentialService()
        {
            var existingCredentialService = HttpHandlerResourceV3Extensions.GetCustomCredentialService();

            if (existingCredentialService != null)
            {
                return(existingCredentialService.CreateNonInteractive());
            }
            return(new CredentialService(new ICredentialProvider[0], nonInteractive: true));
        }
Ejemplo n.º 3
0
        void InitializeDefaultCredentialProvider()
        {
            var credentialService = new CredentialService(
                GetCredentialProviders(),
                OnError,
                nonInteractive: false);

            NuGet.HttpClient.DefaultCredentialProvider = new CredentialServiceAdapter(credentialService);

            HttpHandlerResourceV3Extensions.InitializeHttpHandlerResourceV3(credentialService);
        }
Ejemplo n.º 4
0
        public static ICredentialService CreateNonInteractiveCredentialService()
        {
            var existingCredentialService = HttpHandlerResourceV3Extensions.GetCustomCredentialService();

            if (existingCredentialService != null)
            {
                return(existingCredentialService.CreateNonInteractive());
            }
            var lazyProvider = AsyncLazy.New(() => Enumerable.Empty <ICredentialProvider> ());

            return(new CredentialService(lazyProvider, nonInteractive: true, handlesDefaultCredentials: false));
        }
Ejemplo n.º 5
0
 /// <summary>
 /// The credential service puts itself in a retry mode if a credential provider
 /// is checked. This results in credentials stored in the key chain being ignored
 /// and a dialog asking for credentials will be shown. This method will clear
 /// the retry cache so credentials stored in the key chain will be re-used and a
 /// dialog prompt will not be displayed unless the credentials are invalid. This
 /// should be called before a user triggered action such as opening the Add
 /// Packages dialog, restoring a project's packages, or updating a package.
 /// </summary>
 public static void Reset()
 {
     try {
         var credentialService = HttpHandlerResourceV3Extensions.GetCustomCredentialService();
         if (credentialService != null)
         {
             credentialService.Reset();
         }
     } catch (Exception ex) {
         LoggingService.LogError("Failed to reset PackageManagementCredentialService.", ex);
     }
 }