Microsoft.Alm.Authentication.VstsAadAuthentication.InteractiveLogon C# (CSharp) Méthode

InteractiveLogon() public méthode

Creates an interactive logon session, using ADAL secure browser GUI, which enables users to authenticate with the Azure tenant and acquire the necessary access tokens to exchange for a VSTS personal access token.

Tokens acquired are stored in the secure secret stores provided during initialization.

public InteractiveLogon ( TargetUri targetUri, bool requestCompactToken ) : Task
targetUri TargetUri The unique identifier for the resource for which access is to /// be acquired.
requestCompactToken bool /// Requests a compact format personal access token; otherwise requests a standard /// personal access token. /// Compact tokens are necessary for clients which have restrictions on the size of /// the basic authentication header which they can create (example: Git). ///
Résultat Task
        public async Task<Credential> InteractiveLogon(TargetUri targetUri, bool requestCompactToken)
        {
            BaseSecureStore.ValidateTargetUri(targetUri);

            try
            {
                Token token;
                if ((token = await this.VstsAuthority.InteractiveAcquireToken(targetUri, this.ClientId, this.Resource, new Uri(RedirectUrl), null)) != null)
                {
                    Git.Trace.WriteLine($"token acquisition for '{targetUri}' succeeded.");

                    return await this.GeneratePersonalAccessToken(targetUri, token, requestCompactToken);
                }
            }
            catch (AdalException)
            {
                Git.Trace.WriteLine($"token acquisition for '{targetUri}' failed.");
            }

            Git.Trace.WriteLine($"interactive logon for '{targetUri}' failed");
            return null;
        }