User level: Intermediate
Original publication date: 07/11/2014
Other required products:
By downloading software from the Adobe website you agree to the terms of our license agreement. Please read it before downloading.
In this article, you will learn how to use the example files that replace the default library so that you can view the utility of the authentication calls. The sample files in this article contain an HTML implementation of the library and store API integrated with your Entitlement Server. The template uses APIs that allow you to duplicate entitlement functionality found in the default library and customize it to fit your project. The sample works on both iOS and Android platforms.
Begin by downloading the sample files that are provided at the beginning of this article. The sample contains the HTML implementation and replaces the default library. You can use them as a separate tab of custom store in the iOS application and instead of the default library on Android. The figures below show the various views of the library.
To use the provided template you must have already setup your Entitlement Server. The template uses the new library and store APIs to use the authentication calls. All other features are packaged with your viewer.
Download and decompress the sample files folder to see the contents.
During development, Adobe recommends that you first build and test your content on the desktop using Safari. This allows you to adjust the user interface (UI) without having to generate a new viewer to see each change. When testing on your desktop, the API file is not available, so the viewer loads the data from the Adobe fulfillment XML feed.
While testing on the desktop, ensure that you remove the include for AdobeLibraryAPI.js in the index.html file—otherwise you can't view the files in the desktop browser. When testing on the desktop, if nothing displays, open the debugger to check whether there are file paths that cannot be resolved. For more details on how to use the debugger, have a look on these two articles: Debugging a custom iOS storefront or library and Remote Debugging on Android with Chrome.
The following list contains descriptions of the key files in the template:
- authentication.zip – The file that is uploaded to App Builder. It is included as an example. This file can be uploaded to App Builder as-is for testing purposes.
- AdobeLibraryAPI.js – The file that contains the library and store APIs.
- index.html — The HTML file used to display the content.
- jquery.js — The jQuery library.
To use of this template with your own content, simply complete the following steps:
- Modify index.html.
- Change the test user name and password.
- Upload files to App Builder.
The following sections describe each of these steps in more detail.
To modify index.html, use the following steps.
- Go to the login variable and change the test user name and password with some credentials that work for your Entitlement Server
- If you want to use the code only under iOS, you can change the undefined parameter with null. However, this null parameter doesn't work in Android apps and the user isn't logged in.
- After you install the app, you will see screen similar with Figure 1 on Android and Figure 2 on iOS
- You have two options either to log in using the default display box and entering manually the credentials or to log in with hard-coded values (NOTE: It's necessary to change the hard-coded values in the index.html file).
- After you log in with one of the methods, you will see a screen similar with Figure 3 where the successful message, the user name and the token is displayed.
- Now you have only one option: to Log out. After you click the button, it will appear a screen similar with Figure 4.
Here are the API calls used in this example:
- adobeDPS.authenticationService.login() - Starts a login transaction and has three string parameters: user name, password, and authToken. Requires that isUserAuthenticated is false.
- adobeDPS.authenticationService.userAuthenticationChangedSignal.addOnce() - Signal to indicate that the user's authentication state has changed.
- adobeDPS.authenticationService.displaySignIn() - Asks the authentication service to present the native sign in UI. If currently authenticating or already signed in, UI is not shown.
- adobeDPS.authenticationService.logout() - Starts a logout transaction on this Folio. Requires that isUserAuthenticated be true.
- adobeDPS.authenticationService.isUserAuthenticated - Boolean variable that shows whether a user is currently authenticated. It returns true, if the user is authenticated.
- adobeDPS.authenticationService.authService.userName - String variable that returns the user name of that user. It is null if the user is logged out.
- adobeDPS.authenticationService.authService.token - String variable that returns the authToken associated with that user. It is null if the user is logged out.
There are also the following articles explaining how to use the authentication calls: