예제 #1
0
        private static HttpRequestMessage BuildBearerTokenFromEnvSltRequest(DocuSignSettings dsconfig, string envSlt)
        {
            var request = new HttpRequestMessage(HttpMethod.Post, dsconfig.IDPServerBaseUrl + "/oauth/token");

            request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            string authorizationHeaderValue = string.Format("{0}:{1}", dsconfig.ClientId
                                                            , dsconfig.ClientSecret);
            string base64HeaderValue = Convert.ToBase64String(Encoding.UTF8.GetBytes(authorizationHeaderValue));

            request.Headers.Authorization = new AuthenticationHeaderValue("Basic", base64HeaderValue);

            var content = new FormUrlEncodedContent(new[]
            {
                // For eSeal should be. code from env_slt
                new KeyValuePair <string, string>("grant_type", "docusign:params:oauth:grant-type:envelope-slt"),
                new KeyValuePair <string, string>("env_slt", envSlt),
                // The redirect_uri one is not really used in the TSP flow
                new KeyValuePair <string, string>("redirect_uri", String.Format("https://{0}", "localhost:5001/api/docusigntsp/starttspflow")),
            });

            request.Content = content;

            return(request);
        }
예제 #2
0
 public StartTspFlowModel(DocuSignSettings dsconfig, IHttpClientFactory clientFactory)
 {
     _dsConfig          = dsconfig;
     _httpClientFactory = clientFactory;
 }
예제 #3
0
        public static async Task <SignatureOAuthUserToken> GetBearerTokenFromEnvSltAsync(IHttpClientFactory httpClientFactory, DocuSignSettings dsConfig, string code)
        {
            HttpRequestMessage request = DocuSignService.BuildBearerTokenFromEnvSltRequest(dsConfig, code);

            var client   = httpClientFactory.CreateClient();
            var response = await client.SendAsync(request);

            var responseContent = response.Content.ReadAsStringAsync().Result;

            if (response.StatusCode < HttpStatusCode.OK && response.StatusCode >= HttpStatusCode.BadRequest)
            {
                throw new Exception(response.Headers.ToString() + "\n" + responseContent);
            }

            return(JsonConvert.DeserializeObject <SignatureOAuthUserToken>(responseContent));
        }
 public IndexModel(IConfiguration configuration, DocuSignSettings dsconfig)
 {
     DocuSignIDPBaseURL = dsconfig.IDPServerBaseUrl;
 }
 public DocuSignTspController(DocuSignSettings dsConfig, IHttpClientFactory httpClientFactory)
 {
     _dsConfig          = dsConfig;
     _httpClientFactory = httpClientFactory;
 }