/// <summary>
        /// Gets the token.
        /// </summary>
        /// <param name="clientId">The client identifier.</param>
        /// <param name="clientSecret">The client secret.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns></returns>
        public async Task <TokenResponse> GetToken(String clientId,
                                                   String clientSecret,
                                                   CancellationToken cancellationToken)
        {
            StringBuilder queryString = new StringBuilder();

            queryString.Append("grant_type=client_credentials");
            queryString.Append($"&client_id={clientId}");
            queryString.Append($"&client_secret={clientSecret}");

            String token = await this.GetToken(queryString.ToString(), cancellationToken);

            return(TokenResponse.Create(token));
        }
        /// <summary>
        /// Gets the token.
        /// </summary>
        /// <param name="username">The username.</param>
        /// <param name="password">The password.</param>
        /// <param name="clientId">The client identifier.</param>
        /// <param name="clientSecret">The client secret.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns></returns>
        public async Task <TokenResponse> GetToken(String username,
                                                   String password,
                                                   String clientId,
                                                   String clientSecret,
                                                   CancellationToken cancellationToken)
        {
            StringBuilder queryString = new StringBuilder();

            queryString.Append("grant_type=password");
            queryString.Append($"&client_id={clientId}");
            queryString.Append($"&client_secret={clientSecret}");
            queryString.Append($"&username={username}");
            queryString.Append($"&password={password}");

            String token = await this.GetToken(queryString.ToString(), cancellationToken);

            return(TokenResponse.Create(token));
        }
Exemple #3
0
        public void TestCreate_OK_Null()
        {
            var response = TokenResponse.Create(HttpStatusCode.OK, null);

            Assert.Fail();
        }