Sensorberg Smart Spaces SDK for Android / com.sensorberg.smartworkspace.sdk / UserManager

UserManager

interface UserManager

Manages user authentication. Provides methods for login, logout, change password and the logged-in/out

Types

Status

sealed class Status

Base class for the possible statuses of the SmartWorkspaceSdk

Functions

changePassword

abstract fun changePassword(currentPassword: String, newPassword: String, newPasswordConfirmation: String): LiveData<SimpleResponse<Void>>

Changes the user password on the backend. This option is only valid if the application uses usernamePasswordLogin.

externalTokenLogin

abstract fun externalTokenLogin(authenticationToken: String): LiveData<SimpleResponse<Void>>

Login the user using server-to-server pre-shared authentication token. This is used when the host app backend registers a token for that user on the Smart Workspaces backend.

getStatus

abstract fun getStatus(): LiveData<Status>

Get observable status of the SDK. The Status is a Kotlin sealed class. That means they might contain extra parameters inside such as server messages, or error codes.

getUser

abstract fun getUser(): LiveData<SimpleResponse<User>>

Get a LiveData of the logged-in user. This includes name, email, etc.

logout

abstract fun logout(): Unit

Logs out the user. The status will immediately change to Status.LoggingOut This process might take a couple of seconds to complete and then the status will change to Status.Initializing

oAuth2Login

abstract fun oAuth2Login(redirectedUri: String): LiveData<SimpleResponse<Void>>

Login the user using OAuth2. This usually happens after a Chrome Custom tab was shown and the user successfully authenticated with the oauth2 provider.

usernamePasswordLogin

abstract fun usernamePasswordLogin(username: String, password: String): LiveData<SimpleResponse<Void>>

Login the user with direct username (usually a username or email) and password.