Klipfolio. The KPI Dashboard - Evolved
The KPI Dashboard – Evolved
1-877-233-6149
Contact Us

Password Protected RSS Feeds

Problem:

You want to use a password protected feed in the Klip you are building. This means that you can't just put the feed location in the Klip's <contentsource> tag because the user has to provide a username and password.

Solution:

The general idea is to provide the user with a way to enter a login and password, then construct the feed URL based on what the user enters.

During your onLoad() function, add the following:

var tab = Setup.addTab("User Information");
tab.addText("Please enter your username:");
c_username = tab.addTextField('');
tab.addText("Please enter your password:");
c_password = tab.addTextField('');
c_password.obscured = true;

In the code above, c_username and c_password are global variables. The code above adds a "User Information" tab to the setup window, with two text fields for the user to enter their login information. Setting c_password.obscured to true makes the password field display only asterisks when the user enters their password.During the onRefresh() function, add the following:

var feedURL = "http://" + c_username.value + ":" + c_password.value + "@" + feedLocation;
Engines.Data.process(feedURL);

The feedLocation variable should contain the feed address you want to use, without "http://" in front of it. The feedURL variable will contain a complete URL, built from what the user has entered in the Klip setup window.There is one important thing to note concerning password security. When saving the user's username and password as preferences, the password should be "garbled":

Prefs.setPref("password", garble(c_password.value));
This obscures the password value that is saved in the Klip's preferences file. If the garble() function is not used, then the password is stored as plaintext in the user's Klipfolio Dashboard profile, which could then be read by another person. When loading the password pref, use the coresponding ungarble() function:

c_password.value = ungarble(Prefs.getPref("password"));

Leave a Comment

To leave a comment, you must sign in or register (it's free).

   
Comment Type:
Title:
Comment: