Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
IBM Worklight Mobile Application Development Essentials

You're reading from  IBM Worklight Mobile Application Development Essentials

Product type Book
Published in Feb 2014
Publisher
ISBN-13 9781782177609
Pages 144 pages
Edition 1st Edition
Languages

Creating adapter-based authentication


Adapter-based authentication is the simplest form of authentication provided in Worklight. It uses the adapter procedure/function to validate and authenticate the users and create their sessions. Plus, it provides all the features of the Worklight authentication framework.

Please use the following simple steps to implement adapter-based authentication:

  1. Create a new Worklight project with the name ABADemo; for the application, use the name myAdapterBasedAuthentication.

  2. Add an adapter and give it a name: myAuthAdapter. Paste the following sample function code into the adapter.js file:

    function onAuthRequired(headers, errorMessage){
      errorMessage = errorMessage ? errorMessage : null;
      return {
        authRequired: true,
        errorMessage: errorMessage
      };
    }
    
    function submitUserAuthentication(username, password){
      if (username==="adapter" && password === "adapter"){
        var userIdentity = {
          userId: username,
          displayName: username, 
         ...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}