Issues with Authentication on Sandbox
Monday, June 18, 2018 at 09:17amHi, I'm trying to set up a demonstration project using the sandbox environment but I'm having troubles authenticating with the API.
I initially used the .NET SDK to access the sandbox but when I hit troubles I decided to try and distill the problem down.
What I'm observing is that my first attempt to connect to the sandbox API always yields a 401, even when I am explicitly supplying the API Key in the Authorization header. As long as I use the same HttpClient instance, thereafter I can then get through without problems. I've replicated this behavior in Postman, so I don't believe it is .NET specific.
Here's the code:
private static HttpClient client = CreateClient(); static async Task Main(string[] args) { await Go(client); await Go(client); await Go(client); } private static HttpClient CreateClient() { var handler = new HttpClientHandler() { PreAuthenticate = true, }; var httpClient = new HttpClient(handler) { }; httpClient.DefaultRequestHeaders.Add("Authorization", "Basic {api key goes here}"); httpClient.BaseAddress = new Uri("https://sandbox.esignlive.com/api/"); return httpClient; } private static async Task Go(HttpClient httpClient) { try { var package = await httpClient.GetAsync("packages"); Console.WriteLine($"Got packages: {await package.Content.ReadAsStringAsync()}"); } catch (Exception e) { Console.WriteLine(e.ToString()); } }Outcome:
Got packages: {"messageKey":"error.unauthorised.noSession","message":"Failed to retrieve Session","code":401,"name":"Unauthorized"} Got packages: {"count":0,"results":[]} Got packages: {"results":[],"count":0}I am behind a proxy that I think might be part of the issue, but I am not sure. I had to configure the default .NET proxy as such:
Any ideas on what might be gumming up the works? Thanks.
Reply to: Issues with Authentication on Sandbox
Tuesday, June 19, 2018 at 04:30amReply to: Issues with Authentication on Sandbox
Wednesday, June 20, 2018 at 08:12amReply to: Issues with Authentication on Sandbox
Thursday, June 21, 2018 at 09:03amReply to: Issues with Authentication on Sandbox
Thursday, June 21, 2018 at 11:23amReply to: Issues with Authentication on Sandbox
Monday, June 25, 2018 at 07:57amReply to: Issues with Authentication on Sandbox
Tuesday, June 26, 2018 at 06:11amReply to: Issues with Authentication on Sandbox
Thursday, June 28, 2018 at 07:05amReply to: Issues with Authentication on Sandbox
Thursday, June 28, 2018 at 07:13amReply to: Issues with Authentication on Sandbox
Thursday, June 28, 2018 at 07:30amReply to: Issues with Authentication on Sandbox
Thursday, June 28, 2018 at 07:32amReply to: Issues with Authentication on Sandbox
Thursday, June 28, 2018 at 08:12amReply to: Issues with Authentication on Sandbox
Thursday, June 28, 2018 at 09:07amReply to: Issues with Authentication on Sandbox
Thursday, July 5, 2018 at 06:48pmReply to: Issues with Authentication on Sandbox
Tuesday, July 10, 2018 at 05:52am