Cheetah CES Docs Portal

Navigation
Home
GitHub
Email
Corporate Site


Authentication

« Back to Kits References

(/en-us/loyalty/developer/sdk/android_sdk/pages/09_module_reference.html)

This kit allows users to log into the app using their Cheetah Digital credentials, social accounts and other authentication integration (e.g. JWT). Aside from Login, the kit also includes the following functionalities:

  • Registration
  • Password Functionalities


On this page:

Login

Overview

To include the Authentication kit, open the Gradle Scripts | build.gradle (Module: app) and add the following to the dependencies section:

   implementation 'com.cheetahdigital.android:authentication:<version>'

To start using the Authentication Kit, get the API credentials from Cheetah Digital Console and add it to the string resources of the app. The resource ids should look similar to the one below:

<!-- API Credentials -->
<string name="client_label">Loyalty</string>
<string name="client_url">https://loyalty.demostellar.com</string>
<string name="client_id">ij3hr9q24hfniakutro230923rfuje8r9023rk02</string>
<string name="client_secret">iodufj0wioeu4jtr2094ijdslfjf340tjy3wo</string>

The Authentication Kit also allows developer to integrate the Facebook SDK for Facebook login. Aside from the Cheetah Digital credentials, supply the Facebook Application credentials in the resources and the AndroidManifest.xml.

See sample below:

<!-- Facebook API -->
<string name="facebook_app_id">1234567890</string>
<string name="facebook_authority">com.facebook.app.FacebookContentProvider1234567890</string>
<string name="facebook_namespace">cheetah_loyalty</string>

Sample Facebook entries on the AndroidManifest.xml.

<!-- Start: Facebook SDK -->
<meta-data
   android:name="com.facebook.sdk.ApplicationId"
   android:value="@string/facebook_app_id" />
 
<provider
   android:name="com.facebook.FacebookContentProvider"
   android:authorities="@string/facebook_authority"
   android:exported="true" />
 
<activity
   android:name="com.facebook.FacebookActivity"/>
<!-- End: Facebook SDK -->

For more information about Facebook SDK for Android, see https://developers.facebook.com/docs/android/.

For Google Sign In, include google-services.json in the app project. For more information on Google Sign In for Android, see https://developers.google.com/identity/sign-in/android/start.

Permissions

Several permissions are need to be declared in the AndroidManifest.xml if using Google Signin or if Biometrics login is enabled.

<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.USE_FINGERPRINT"/>

Launching the Login Screen

To use the built-in Login Activity from the Authentication Kit, create a new Activity that will extend LoginActivity.java. The LoginActivity is an abstract class, and important methods for the Login will need to be implemented.

For example, on the app project, create a MyLoginActivity.java class then add LoginActivity.java as the superclass.

public class MyLoginActivity extends LoginActivity {
	@Override
    public void onLogin() {
        // TODO: Add Intent to Main Screen of the App
    }

    @Override
    public void onRegisterButtonClicked() {
        // TODO: Add Intent to Registration Screen
    }

    @Override
    protected void initializeFacebookButtonLogin() {
        FacebookHelper.initializeFacebookButtonLogin(this, R.id.fb_sign_in_button,
                FacebookHelper.Permissions.PUBLIC_PROFILE, FacebookHelper.Permissions.EMAIL,
                FacebookHelper.Permissions.USER_FRIENDS);
    }

    @Override
    public void processErrorWithMember(HashMap<String, Object> memberDetails, HashMap<String, List<String>> errorList) {
        // TODO: Handle 4032 Error here
    }
}

Then add this new MyLoginActivity class into the AndroidManifest.xml and call it from the application to start the Login screen.

Theme Customization

The Kit leverages on Android’s support for Styles and Themes. Overriding Styles and Themes per Widget, Activity, or Application can change the app’s appearance. To read more about this, please visit our Styles and Themes document.

Layout Customization

Customizing the Login Screen

In order to modify the layout of the Login Screen to suit your app design, you must create a copy of the fragment_login.xml and modify it as desired.

To read more about this, please visit our Layout Customization via XML document.

Fully Custom UI

If changing the layout is not enough for the requirements, full customization is applicable. To fully customize the Login function, build the app using AuthenticationAPI’s methods.

Login

login(AuthenticationFieldParams fieldParams, Listener<Authentication> callback)

Registration

Launching the Registration Screen

Create your own MyRegistrationActivity and extend the abstract class RegistrationActivity. Implement the required methods and add it to the AndroidManifest.xml. MyRegistrationActivity can be used in the onRegisterButtonClicked() method of the LoginActivity.

Theme Customization

The Kits leverage on Android’s support for Styles and Themes. Overriding Styles and Themes per Widget, Activity, or Application can change the app’s appearance. To read more about this, please visit our Styles and Themes document.

Layout Customization

Customizing the Registration Screen

To change the layout of the Registration Screen, create a copy of the fragment_registration.xml in the app’s directory and modify the layout as desired.

To read more about this, please visit our Layout Customization via XML document.

Fully Custom UI

If changing the layout does not meet the requirements of the app, you may create your own Registration activity and use the following AuthenticationAPI’s methods:

Regular Sign Up

signup(AuthenticationFieldParams fieldParams, Listener<SuccessResponse> listener)

Reset Password

Launching the Reset Password Screen

  1. Add the ResetPasswordActivity in the AndroidManifest.xml of the app:

     <activity android:name="com.cheetahdigital.authentication.ui.resetpassword.ResetPasswordActivity">
        <intent-filter>
            <action android:name="${applicationId}.RESET_PASSWORD" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
     </activity>
    
  2. Then start the Activity with the use of the Actions from the MainActivity.java:

     startActivity(new Intent(Actions.Authentication.getResetPasswordAction(MainActivity.this));
    

Theme Customization

The Kits leverage on Android’s support for Styles and Themes. Overriding Styles and Themes per Widget, Activity, or Application can change the app’s appearance. To read more about this, please visit our Styles and Themes document.

Layout Customization

Customizing the Reset Password Screen

In order to modify the way the reset password screen looks, you must override the activity_change_password.xml in your app.

To read more about this, please visit our Layout Customization via XML document.

Fully Custom UI

A full customization can be done using the AuthenticationAPI’s method listed below:

changePassword(AuthenticationQueryParams queryParams, AuthenticationFieldParams fieldParams, ListenerModel<BaseModel<Object>, Object> listener)

Reset Password

resetPassword(AuthenticationFieldParams fieldParams, Listener<SuccessResponse> listener)


« Back to Kits References