Im trying to build an C# application that adds a user automatically to DUO.
The documentation is not clear on how to do this online.
Here is the code im using
var client = new HttpClient();
var Request = new HttpRequestMessage(HttpMethod.Post, "https://api-2cf9xxxx.duosecurity.com/admin/v1/users");
Request.Content = new StringContent(string.Empty, Encoding.Unicode, "application/x-www-form-urlencoded");
Request.Headers.Add("X-Duo-Date", DuoDate);
Request.Headers.Add("Authorization","Basic " + val);
Request.Content = new FormUrlEncodedContent(new Dictionary<string, string>
{{"username:",ADAccountNameStr}});
Request.Headers.Add("Host", DuoHostname);
var response = await client.SendAsync(Request,HttpCompletionOption.ResponseHeadersRead);
var responseContent = await response.Content.ReadAsStringAsync();
This is this Request and header Responses
Tue, 22 Nov 2022 15:19:41 +0000
POST
api-2cxxxxx.duosecurity.com
/admin/v1/users
username:jdoe
Method: POST, RequestUri: 'https://api-2cfxxxxx.duosecurity.com/admin/v1/users', Version: 1.1, Content: System.Net.Http.FormUrlEncodedContent, Headers:
{
X-Duo-Date: Tue, 22 Nov 2022 15:19:41 +0000
Authorization: Basic RElHVEsxWTBFOERENjdJU0NVNTY6MmM0NWU4MDBhNzkyOGE3YmY5NjBlNDI0MDI3NDZjYzY1Y2MzYzhkYQ==
Host: api-2cfxxxxxx.duosecurity.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 16
}
StatusCode: 401, ReasonPhrase: 'Unauthorized', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Connection: keep-alive
Date: Tue, 22 Nov 2022 15:19:41 GMT
Server: Duo/1.0
Content-Length: 86
Content-Type: application/json
}
And the error that im getting is
"code": 40103, "message": "Invalid signature in request credentials", "stat": "FAIL"
Can anyone see where im going wrong, the only thing that seems oncorrect is the content length.