Ejemplo n.º 1
0
        public IAuthorizationState ExchangeUserCredentialForTokenAsync(string userName, string password, IEnumerable <string> scopes = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            var request = new AccessTokenResourceOwnerPasswordCredentialsRequest(this.AuthorizationServer.TokenEndpoint, this.AuthorizationServer.Version)
            {
                RequestingUserName = userName,
                Password           = password
            };

            return(this.RequestAccessTokenAsync(request, scopes, cancellationToken));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Exchanges a resource owner's password credential for OAuth 2.0 refresh and access tokens.
        /// </summary>
        /// <param name="userName">The resource owner's username, as it is known by the authorization server.</param>
        /// <param name="password">The resource owner's account password.</param>
        /// <param name="scopes">The desired scope of access.</param>
        /// <returns>The result, containing the tokens if successful.</returns>
        public IAuthorizationState ExchangeUserCredentialForToken(string userName, string password, IEnumerable <string> scopes = null)
        {
            var request = new AccessTokenResourceOwnerPasswordCredentialsRequest(this.AuthorizationServer.TokenEndpoint, this.AuthorizationServer.Version)
            {
                UserName = userName,
                Password = password,
            };

            return(this.RequestAccessToken(request, scopes));
        }