Title: API key in HTTP header &#8211; key:value
Last modified: September 8, 2023

---

# API key in HTTP header – key:value

 *  Resolved [haakonme](https://wordpress.org/support/users/haakonme/)
 * (@haakonme)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/api-key-in-http-header-keyvalue/)
 * I need to connect JSON Content Importer to an API which requires a slightly different
   authentication format than what may currently be available on the “Basic Settings”
   page.
 *  I get
 * “Missing Authorization field in HTTP-Header…”
 * and have tried the two different ways offered there, and some variations to transform
   to those formats, but without any luck so far.
 * I can connect and receive data from the endpoint with both Postman and cURL without
   any troubl
 * Postman: Authorization, Type = API Key, Key = some_access_key, Value = some_password.
 * cURL: curl –location ‘endpoint URL’ –header ‘some_access_key: some_password’
 * Apologies if I am doing it wrong, but I currently believe that in addition to
 * “Bearer Authorization:ACCESSKEY”
   “Authorization:ACCESSKEY”
 * I think I need
 * 
   “Authorization: SOME_ACCESS_KEY:SOME_PASSWORD”
 * in the header, and I do not understand how or if I can currently do that.
 * Cheers,
 * Haakon

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [berkux](https://wordpress.org/support/users/berkux/)
 * (@berkux)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/api-key-in-http-header-keyvalue/#post-17036186)
 * Hi,
   try
 *     ```wp-block-code
       nobearer Authorization: SOME_ACCESS_KEY:SOME_PASSWORD
       ```
   
 * in the general JCI settings at Tab “Basic Settings”
 * Bernhard
 *  Thread Starter [haakonme](https://wordpress.org/support/users/haakonme/)
 * (@haakonme)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/api-key-in-http-header-keyvalue/#post-17036556)
 * Thank you, Bernhard, but I am afraid this did not work. I get the same error 
   message.
 * When I look at the cURL header, which works, it contains only SOME_ACCESS_KEY:
   SOME_PASSWORD, i.e. not the Authorization: bit.
 * I tried to use your suggestion without the Authorization bit, i.e.
 *     ```wp-block-code
       nobearer SOME_ACCESS_KEY:SOME_PASSWORD
       ```
   
 * but this does not work either.
 * Does the code perhaps add “Authorization:” to the header automatically?
 * Cheers,
 * Haakon
 *  Plugin Author [berkux](https://wordpress.org/support/users/berkux/)
 * (@berkux)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/api-key-in-http-header-keyvalue/#post-17045638)
 * Hi, 
   <<Does the code perhaps add “Authorization:” to the header automatically?
   >>Yes.In a few days, the next version will have a way to add http-headers as 
   you need it.
 *  Thread Starter [haakonme](https://wordpress.org/support/users/haakonme/)
 * (@haakonme)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/api-key-in-http-header-keyvalue/#post-17048844)
 * Thank you, Bernard! 🙂
 * I did a minor hack to get it working, with
 * `  // Extract API key and API password from user input
          $user_input = $
   acckey;       list($api_key, $api_password) = explode(':', $user_input, 2);  
   $header = array( $api_key => $api_password)
 * and then I added a conditional header, as I needed to pass the header a bit differently
   with this API.
 * I have used a log tool to log the HTTP request from two WordPress-plugins which
   fetch the same API.
 * This works:
 * “headers”: {
   “SOME_KEY”: “SOME_PASSWORD”}
 * This does not work, which is what I got from JSON Content Importer:
 * “headers”: [
   “SOME_KEY:SOME_PASSWORD”]
 * Once I got it working, I noticed a few things.
 * First, the plugin works very well – thank you! 🙂
 * Three issues has surfaced.
    1. The template generator says the valid JSON from the API is invalid JSON. I have
       verified the API does provide valid JSON. When I ignore this, and write the 
       template according to the documentation myself, the plugin works wonderfully.
    2. When using the JCILISTITEM with a subloop-array, it is sometimes not possible
       to have another {key} above it, then the above {key} will not be displayed at
       all, but the JCILISTITEM is still shown. I suspect the disappearing above {key}
       may contain some characters that are not properly escaped, but I have not looked
       into it. I found a work-around in creating another JCI-block for the above {
       key}.
    3. I need to add two or more different API sources, and they all have different
       authentication methods. The JCI Settings page currently allows one API authentication
       to be set. If this could be a list for different APIs, then that would be really
       nice. The JCI block does allow different authentication methods, but it currently
       does not support the header method I need – looking forward to the enhancement.
 * Cheers,
 * Haakon
 *  Plugin Author [berkux](https://wordpress.org/support/users/berkux/)
 * (@berkux)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/api-key-in-http-header-keyvalue/#post-17073319)
 * Hi Haakon,
   ok, this is a way to do that.In the new Version 1.5.3 you can set 
   http-Headerfieldpairs in the Tab “Basic Settings”.Bernhard
 *  Thread Starter [haakonme](https://wordpress.org/support/users/haakonme/)
 * (@haakonme)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/api-key-in-http-header-keyvalue/#post-17231909)
 * Thank you, Bernhard, sorry for the untimely answer – this is great! 🙂

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘API key in HTTP header – key:value’ is closed to new replies.

 * ![](https://ps.w.org/json-content-importer/assets/icon-256x256.png?rev=3464653)
 * [Get Use APIs - JSON Content Importer](https://wordpress.org/plugins/json-content-importer/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/json-content-importer/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/json-content-importer/)
 * [Active Topics](https://wordpress.org/support/plugin/json-content-importer/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/json-content-importer/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/json-content-importer/reviews/)

## Tags

 * [authorization](https://wordpress.org/support/topic-tag/authorization/)

 * 6 replies
 * 2 participants
 * Last reply from: [haakonme](https://wordpress.org/support/users/haakonme/)
 * Last activity: [2 years, 6 months ago](https://wordpress.org/support/topic/api-key-in-http-header-keyvalue/#post-17231909)
 * Status: resolved