示例#1
0
        /// <summary>
        /// Create signature for adding request header.
        /// </summary>
        /// <param name="client"></param>
        /// <param name="endpoint"></param>
        /// <param name="methodType"></param>
        /// <returns></returns>
        private string CreateSignature(Client client, Endpoint endpoint, MethodType methodType)
        {
            var signature = string.Empty;

            if (!string.IsNullOrEmpty(client.CertificatePrivateKey) && endpoint.GrantType == GrantType.AuthorizationCode)
            {
                if (methodType == MethodType.Post)
                {
                    signature = CertificateUtils.CreateSignature(client.CertificatePrivateKey, oAuth2.Token.AccessToken, endpoint.BodyParameters == null ? null : JsonConvert.SerializeObject(endpoint.BodyParameters));
                }
                else
                {
                    signature = CertificateUtils.CreateSignature(client.CertificatePrivateKey, oAuth2.Token.AccessToken, (endpoint.QueryParameters == null || endpoint.QueryParameters.Count() == 0) ? null : "?" + Request.CreateQueryString(endpoint.QueryParameters));
                }
            }
            return(signature);
        }