humanmade/WP-Remote-WordPress-Plugin — pull request #21 by lucanos (2013-04-22 17:50:19+00:00)
Title: Manage Multiple API Keys - Deployment across Multiple Environments

I had an interesting usage case.

I use WPRemote to manage a number of websites, including instances where I am managing Development, Staging and Production installations of the same website. When I push/pull updates (using Duplicator), I had to constantly reset the WPRemote API Key to match the correct domain. If I didn't, I would lose the monitoring functionality of WPRemote until I remembered and got around to it.

So, I made a fork of this Github Project.

Now, instead of recording the API Key as a plain text option in Wordpress, I store it as an array, with each of the array elements being a subarray consisting of a 'pattern' (the domain, or a regular expression pattern starting with '/') and an 'apikey'.

These are administered through a basic, but effective, Option Page which is added to the Settings menu.

When API calls are made, the set of API keys are checked and the apikey associated with the first matched pattern is used to authenticate the request.

I have tested this behaviour in some of my environments and it works OK.