Skip to main content

  • Login | Forgot Password?
Ribbit Developer logo

Storing Developer Credentials in Google Chrome

Submitted by jwill on Sun, 2009-12-27 14:41

Recently, we covered the building blocks of building extensions for Chrome. In this post, I show you how to use HTML5 localStorage to store developer credentials securely.

Storing Developer Credentials

When we set up the manifest file to store the properties of our extension, We designated that we would use an options html page to input our Ribbit credentials for the application. Using an options page allows us to package our extension and give it to friends to use without exposing our information. To login to a Ribbit developer account, we need a couple of form elements to identify our application and the phone number that will be rung when a call is made:

Ribbit Chrome Extension

Clicking "Save" will store the credentials in HTML5 localStorage. Rest assured that only our extension can read those settings and you are in no means sharing the data with other extensions or Google:

function save_options() {
    var token = document.getElementById("token");
    var appId = document.getElementById("appId");
    var username = document.getElementById("username");
    var pwd = document.getElementById("password");
    var phone = document.getElementById("phone");

    localStorage["token"] = token.value;
    localStorage["appId"] = appId.value;
    localStorage["phone"] = phone.value;
    localStorage["username"] = username.value;
    localStorage["password"] = pwd.value;
    
    // Update status to notify user.
    var status = document.getElementById("status");
    status.innerHTML = "Options saved."
    setTimeout(function() {
        status.innerHTML = "";
    }, 750);
    
    console.log("Options saved to localStorage.");
}

When the options page is loaded, the page is automatically repopulated with the stored data

 function restore_options() {
    var token = localStorage["token"];
    if (token == "") {
        return;
    }
    var appId = localStorage["appId"];
    var phoneNumber = localStorage["phone"];
    var username = localStorage["username"];
    var password = localStorage["password"];
    
    var tokenId = document.getElementById("token");
    var app = document.getElementById("appId");
    var phone = document.getElementById("phone");
    var user = document.getElementById("username");
    var pwd = document.getElementById("password");
    
    tokenId.value = token;
    app.value = appId;
    phone.value = phoneNumber;
    user.value = username;
    pwd.value = password;
    
    console.log("Restoring options from localStorage.");
}

We can reach the options page of any installed extension by navigating to chrome://extensions and clicking the associated Options button.

Ribbit Chrome Extension

Logging In

In the following snippet, we are telling the extension to use the stored credentials to login whenever the popup page is opened.

function init() {
    var token = localStorage["token"];
    var appId = localStorage["appId"];
    var username = localStorage["username"];
    var password = localStorage["password"];
    
    if (token != "") {
        Ribbit.init(token, appId);
        Ribbit.Login(loginCallback, username, password);
        console.log("Attempting login with stored credentials.");  
    }
    
    console.log("Attempting login");                
}

init();

After login is completed, you'd can call functions like in any other Ribbit Javascript application.

  • Applications
  • chrome
  • chrome extension
  • google chrome
  • ribbit
  • ribbit chrome extension
  • jwill's blog
  • Login or register to post comments
  • Share/Save

Ribbit Photos

Ribbit's Voice-to-Text Service AssuranceInc.: The Best Voicemail Management ServicesFirst Camera PhoneRibbit Mobile: Online Message InboxRibbit for Salesforce brings you: SMS MessagesRibbit for Windows 7

See more photos at Flickr

Ribbit Conversations

  • Tips from Ribbit --> Validating USA and UK phone numbers from @sant1t1 http://su.pr/1VYkoI — 4 days 7 hours ago
  • @martyzigman: I would love to know more about this new CRM integration you are building, sounds good. — 4 days 14 hours ago
  • If you are developing a Ribbit powered application, let us know. We want to love on you a little bit. http://su.pr/6XqZSv — 1 week 3 days ago
  • I don't care what the CEO says, most important *thing* in the room is the candy bowl. <smile> http://yfrog.com/j677209011j — 1 week 4 days ago
  • RT @kevinmarks: me talking about Buzz + open web to GTUG coming up in a few minutes live here -- http://www.building43.com/realtime/ — 1 week 5 days ago
  •  
  • 1 of 60
  • ››
more

Follow Ribbit

 

            

            

           

Categories

  • .NET
  • AIR
  • Applications
  • Articles and Media Mentions
  • Challenge
  • Code
  • Community
  • Contest
  • Design
  • Events
  • Feature
  • Flash
  • Flash Toolkit
  • Flex
  • Flex SDK
  • Gallery
  • General
  • Inside Ribbit
  • Interviews
  • News
  • Newsletter
  • PHP
  • REST
  • Role Playing
  • Silverlight
  • Tips &amp; Tricks
  • Uncategorized
  • Wish List

Archives

  • March 2010
  • February 2010
  • January 2010
  • December 2009
  • November 2009
  • October 2009
  • September 2009
  • August 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009
  • March 2009
  • February 2009
  • January 2009
  • December 2008
  • November 2008
  • October 2008
  • September 2008
  • August 2008
  • July 2008
  • June 2008
  • May 2008
  • April 2008
  • March 2008
  • February 2008
  • January 2008
  • December 2007
  • November 2007
  • October 2007
  • September 2007
  • August 2007
  • November 1999

 

               

               

  • Company
    • Corporate Site
    • About Us
    • Careers
    • Contact Us
    • LegalPrivacy
    • News
    • Media Kit
  • Products
    • Platform
    • Mobile
    • Salesforce
    • Oracle
  • Solutions
    • Digital Agencies
    • Carriers
    • Systems Integrators
    • Hosted Contact Centers
  • Community
    • Corporate Blog
    • Developer Blog
    • CRM Blog
    • Moble Blog
    • Idea Wall
    • Events Calendar
  • Support
    • Developer Help
    • Ribbit for Salesforce Help
    • Ribbit for Oracle Help
    • Ribbit Mobile Help
    • Feedback
    • Developer Forums
    • Ribbit Mobile Forum
  • Developers
    • Developer Center
    • Develop for Ribbit Mobile
    • Register
    • Ribbit Labs

© 2010 Ribbit Corporation. All Rights Reserved.