Hi there,
I’ve set up ApiKey authentication by following the guide: http://docs.servicestack.net/api-key-authprovider
It works fine, when I construct the client as follows:
var baseUrl = "http://encryptedmessaging.com:8088";
var apiKey = "vMz2g6CxtZi2cnqG3Da-CZg5bl_d7E_T";
var client = new JsonServiceClient(baseUrl)
{
Credentials = new NetworkCredential(apiKey,"")
};
var authResponse = client.Send(new Authenticate());
With an encrypted client however, this the above does not work:
string publicKeyXml = client.Get(new GetPublicKey());
IEncryptedClient encryptedClient = client.GetEncryptedClient(publicKeyXml);
var authResponse = client.Send(new Authenticate());
Returns ‘Invalid EncryptedMessage’ when Credentials = new NetworkCredential(apiKey,"")
is set on the client. Not setting the Credentials and calling Authenticate returns Unauthorized (of course because I did not set the API key anywayre).
Question:
How to set the API Key in the Authenticate object, in order for Encrypted Messaging to work with API Keys?
I’ve tried
var authResponse = encryptedClient.Send(new Authenticate
{
provider = "apikey",
UserName = apiKey,
Password = ""
});
and am getting ‘Unauthorized’ back.
Thanks in advance