/// <summary>
        /// Authenticates the user using the specified username and password.
        /// </summary>
        /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
        /// <returns>The <see cref="AuthenticationRecord"/> of the authenticated account.</returns>
        public virtual async Task <AuthenticationRecord> AuthenticateAsync(CancellationToken cancellationToken = default)
        {
            // get the default scope for the authority, throw if no default scope exists
            string defaultScope = KnownAuthorityHosts.GetDefaultScope(_pipeline.AuthorityHost) ?? throw new CredentialUnavailableException(NoDefaultScopeMessage);

            return(await AuthenticateAsync(new TokenRequestContext(new string[] { defaultScope }), cancellationToken).ConfigureAwait(false));
        }
        /// <summary>
        /// Authenticates the user using the specified username and password.
        /// </summary>
        /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
        /// <returns>The <see cref="AuthenticationRecord"/> of the authenticated account.</returns>
        public virtual AuthenticationRecord Authenticate(CancellationToken cancellationToken = default)
        {
            // get the default scope for the authority, throw if no default scope exists
            string defaultScope = KnownAuthorityHosts.GetDefaultScope(_pipeline.AuthorityHost) ?? throw new CredentialUnavailableException(NoDefaultScopeMessage);

            return(Authenticate(new TokenRequestContext(new string[] { defaultScope }), cancellationToken));
        }
Ejemplo n.º 3
0
        internal MsalConfidentialClientOptions(string tenantId, string clientId, CredentialPipeline pipeline)
        {
            TenantId = tenantId;

            ClientId = clientId;

            AttachSharedCache = false;

            Pipeline = pipeline;

            AuthorityHost = KnownAuthorityHosts.GetDefault();
        }
Ejemplo n.º 4
0
        internal MsalConfidentialClientOptions(string tenantId, string clientId, TokenCredentialOptions options)
        {
            TenantId = tenantId;

            ClientId = clientId;

            AttachSharedCache = (options as ITokenCacheOptions)?.EnablePersistentCache ?? false;

            Pipeline = CredentialPipeline.GetInstance(options);

            AuthorityHost = options?.AuthorityHost ?? KnownAuthorityHosts.GetDefault();
        }
 internal DeviceCodeCredential(Func <DeviceCodeInfo, CancellationToken, Task> deviceCodeCallback, string tenantId, string clientId, CredentialPipeline pipeline, TokenCredentialOptions options)
     : this(deviceCodeCallback, clientId, pipeline, pipeline.CreateMsalPublicClient(clientId, tenantId, redirectUrl : KnownAuthorityHosts.GetDeviceCodeRedirectUri(pipeline.AuthorityHost).ToString(), options as ITokenCacheOptions))
 {
 }