.NET wrapper/ setting API key programmatically (not with App Config)

Is it possible to use the .NET wrapper without using the app config for the api key value? I'd like to set that value programmatically, rather than hard-coding it.


hairgamiMaster, 6 years ago

It appears the apiKey is pulled from the AppConfig file and the .NET wrapper doesn't provide any way to set it programmatically. It looks like I will need to use the source code for the .NET wrapper and alter it so that I can set the API on the fly.

If there is an easier way to do this, I'd love to know.


tobyb tobyb, 6 years ago

Hi hairigamiMaster,

You can set the authentication used by the .Net wrapper by calling the HttpHelper.OverrideAuthenticationCredentials method. This should allow you to store your API Key anywhere, or use multiple keys in a single app.

Supposing your API Key was abc123 you'd call

HttpHelper.OverrideAuthenticationCredentials("abc123", "")

See why 200,000 companies worldwide love Campaign Monitor.

From Australia to Zimbabwe, and everywhere in between, companies count on Campaign Monitor for email campaigns that boost the bottom line.

Get started for free