Skip to main content
Version: 1.1.0

Authenticating Users

When a user wants to order a photo project or store it in the cloud, we need to make sure that the user is authenticated. For this the ip.labs Mobile SDK supports the WipeSSO solution which is a server-to-server protocol to sync user sessions from your backend to our systems.

WipeSSO

While we cannot explain the implementation of the WipeSSO protocol in detail here, it is mainly based on a session ID which is used by our systems to get user information from your backend. This session ID has to be generated from your systems for each authenticated user session and can be passed to the ip.labs Mobile SDK in certain situations.

For more information and support on implementing the WipeSSO protocol in your backend, please ask your contact person at ip.labs.

Handling Authentication Requests from the Editor

Our editors offer the functionality to save a user’s photo projects in the cloud. When the user chooses to save a photo project in the cloud, the editor requires an authenticated session and then the handleRequestSessionId callback will be called. When implementing the EditorCallbacks interface, you will have to handle this request by either calling the authenticateCallback once you gained the WipeSSO session ID from your backend or the cancelAuthenticationCallback if an authentication was not possible.

caution

Please make sure to either call authenticateCallback or cancelAuthenticationCallback. Otherwise the editor might end up in an inconsistent state.

override fun requestSessionId(
authenticateCallback: (String) -> Unit,
cancelAuthenticationCallback: () -> Unit
) {
val user = viewModel.getUser()

if (user != null) {
authenticateCallback(user.sessionId)
} else {
showLoginDialog(authenticateCallback, cancelAuthenticationCallback)
}
}

Another situation, where the session ID can be necessary, is when a photo product gets ordered by the user, which is explained in Ordering.

Logout

After you have passed a session ID to the editor and the user was successfully authenticated with it, the editor will cache this state for the predefined lifespan of a user session in our backend (usually six hours). Within this time frame the user can e.g. save projects in the cloud without the Mobile SDK asking for authentication again.

If however you want to reset this authenticated state (e.g. in case you provide a logout functionality for your users), you can explicitly call the logout method:

import de.iplabs.mobile_sdk.IplabsMobileSdk

class MainActivity : AppCompatActivity() {
fun logout() {
viewLifecycleOwner.lifecycleScope.launch {
IplabsMobileSdk.logout()
}
}

// Other activity methods…
}

This causes the user session to no longer be authenticated and makes the Mobile SDK ask for authentication again the next time a functionality is triggered, that requires an authenticated state.

info

The ip.labs Mobile SDK keeps the authenticated state, even when the user quits the app. If you don’t want to persist your user sessions between app launches, you should call the logout method during app termination or (if that is not an option) right after the next app launch.