.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, 4 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, 4 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", "")

Join 200,000 companies around the world that use Campaign Monitor to run email marketing campaigns that deliver results for their business.

Get started for free