Tutorial 2.1: Native Authentication

There are many ways to authenticate with Cleeng on various devices. We highly recommend to create a login/registration form in your app. Once submitted, data shoud be passed to the middleware where proper Cleeng API calls will be made in order to generate Cleeng customerToken.



Registration


Email registration

Step 1. User enters required data (email + password) in your custom native registration form fields. App sends data to middleware

Step 2. Middleware makes requests to the Cleeng API method: registerCustomer() and receives the “customerToken” if successful.

Step 3. Middleware returns all required data back to application, including the “customerToken”

Step 4. Use customerToken and proceed with in-app authentication and further entitlement check.


Flow chart:
Cleeng iOS regitration flow

Login


Login with email

Step 1. User enters required data (email + password) in your custom native form fields. App sends data to middleware

Step 2. Middleware makes requests to the Cleeng API method: generateCustomerTokenFromPassword() and receives the “customerToken” if successful.

Step 3. Middleware returns all required data back to application, including the “customerToken”

Step 4. Use customerToken to check the entitlement and display the premium content. getAccessStatus


Flow chart:
Cleeng iOS login email flow


Connect with facebook / google

Facebook and google authentication process has no visible Login or Registration, instead we have "Connect", while the flow is the same either end user wants to login or register.


Facebook

Connect with Facebook provides its unique facebook_id. This is the base for authentication on Cleeng side.

Step 1. User decides to connect with facebook. (Integration with Facebook app is done on client side)

Step 2. When Facebook returns its id after successful "connect" action, at this point we can't say if this customer is new or not. To validate it assume that customer is returning and use: generateCustomerTokenFromFacebook() which return the information about successful login providing customerToken

Step 3. If customerToken won't be returned after Step 2. it means that customer does not exist in Cleeng database. In this case, registerCustomer() has to be used with filled "facebookId" parameter.

Step 4. customerToken is return from registerCustomer() or generateCustomerTokenFromFacebook() method. Use customerToken to check the entitlement and display the premium content. getAccessStatus


Flow chart:
Cleeng facebook regitration flow


Google

Id returned by Google is simply customer email. This is why flow described underneath is a little bit different than Facebook.

Step 1. User decides to connect with google. (Integration with Google app is done on client side)

Step 2. When Google returns its id (email) after successful "connect" action, at this point we can't say if this customer is new or not. To validate it assume that customer is returning and use: generateCustomerToken() which return the information about successful login providing customerToken

Step 3. If customerToken won't be returned after Step 2. it means that customer does not exist in Cleeng database. To create customer , registerCustomer() has to be used.

Step 4. customerToken is return from registerCustomer() or generateCustomerToken() method. Use customerToken further to check the entitlement and display the premium content. getAccessStatus


Flow chart:
Cleeng google regitration flow


Password recovery

Step 1. User enters email in your custom remind password form. Mobile app sends email address to middleware.

Step 2. Middleware makes requests to the Cleeng API => requestPasswordReset()

Step 3. User receives an email with http end-point that links to prepared password reset page in client web-application and contains the resetPassword token

Step 4. Web-application triggers => updateCustomerPassword()

Step 5. User resets password on the web application