Exemplo n.º 1
0
        /// <summary>
        /// Creates a VssCredentials object and returns it.
        /// </summary>
        public async Task <VssCredentials> CreateVssCredentialsAsync(Uri baseUri, bool useAad)
        {
            if (_credentials != null)
            {
                return(_credentials);
            }

            if (_pat != null)
            {
                return(_helper.GetPATCredentials(_pat));
            }

            return(await _helper.GetCredentialsAsync(baseUri, useAad, _credentialBytes, null)
                   .ConfigureAwait(false));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a VssCredentials object and returns it.
        /// </summary>
        public async Task <VssCredentials> CreateVssCredentialsAsync(Uri baseUri, bool useAad)
        {
            if (_credentials != null)
            {
                return(_credentials);
            }

            if (_pat != null)
            {
                return(_helper.GetPATCredentials(_pat));
            }

#if NET_CORE
            // If the user name is explicitly provided call a different auth method that's
            // not going to query the OS for the AAD user name (which is, btw, disallowed on CoreCLR).
            if (_userName != null)
            {
                return(CreateVssCredentialsForUserName(baseUri));
            }
#endif // NET_CORE
            return(await _helper.GetCredentialsAsync(baseUri, useAad, _credentialBytes, _pat, PromptBehavior.Never, null)
                   .ConfigureAwait(false));
        }