Adding Basic Authentication Headers to a Request

By | November 16, 2018

If your web feed requires an HTTP Basic Authentication header you can add the header information as part of your feed definition.

Note, if you use a basic authentication header with your feed be sure to use a URL that begins with https to ensure that the username and password in the header are not decodable by a third party.

The first step is to get the encoded header value for the username and password. Fortunately this is simple, just navigate to https://www.blitter.se/utils/basic-authentication-header-generator/ then enter the username and password for the feed  and click the “Generate Header” button:

Copy everything from “Basic” to the end of the line (eg “Basic Ym9iOlRlc3Rpbmch”).

Now go into the dashboard for your site and select Transform -> Feeds from the left menu. Edit the feed that needs Basic Authentication and click the “Add Parameter” button to the right of “Feed Parameters”. Set the parameter name to “Authorization”, set the type to “Header”, set the “Value comes from” menu to “Static Text” and the “with name” input to the value you copied above:

Click the “Update Feed” button in the lower right to save the change. The feed will now send the header with the feed request. If you’ve used the right username and password any Transform instances that use this feed should load properly.

If you have more than one feed that uses the same username and password you could save that information in Transform -> Settings. Then in the feed set “Value comes from” to “Setting” and select the name of the setting you created. If you need to change the username and password in the future you’ll only need to change the value in the setting, all feeds with that setting will be updated.