Support for api_key authorization.

Here are the changes to support api_key. Let me know if you have any concerns. Thanks!