Framework for Android app
Configure the simplest way to work with User login and auth
Telematics authorization library for Android
Description
This library is created by DATA MOTION PTE. LTD. and allows you to integrate with our UserService API in a few steps.
LoginAuth Framework main functions:
- Register
deviceToken
for each new Telematics SDK user. - Refresh the
accessToken (JWT)
when it is expired. - Authorize existing SDK user
- Get authorized user profile info
- Update authorized user profile info
Credentials
Before you start using the library, make sure you registered a company account in the DataHub and obtained InstanceId
andInstanceKey
. If you are new, please refer to the documentation and register your company account in DataHub. Sing Up
LoginAuth Framework setup
Here you can find a short video guide, how to add LoginAuth Framework to your iOS app:
Basic concepts
deviceToken
- is the main individual SDK user identifier for your app. This identifier is used as a key across all our services.
accessToken
- or JSON Web Token (JWT) is the main UserService API key, that allows you to get user individual statistics and user scoring by UserService APIs calls.
refreshToken
- is a secret key that allows you to refresh the accessToken
when it expires.
Setup
- Add our maven-repository to your
build.gradle
file:
maven {
url "https://s3.us-east-2.amazonaws.com/android.telematics.sdk.production/"
}
- Import library:
dependencies {
implementation "com.telematicssdk:auth:1.0.0"
}
- If you are using R8 or ProGuard add this line to options:
-keep public class com.telematicssdk.auth.** {*;}
Example
Let's dive in and see the library's API. The main entry point of the library is TelematicsAuth
object.
It's a Kotlin Object
(or static class for Java users) that contains inside all methods.
Every method returns a Task
class. It's a task that should be processed and contains inside callbacks about success or error.
Let's see how it work. In this example we will register a new empty user (without additional fields):
Call TelematicsAuth.createDeviceToken
method that takes an instanceId
, instanceKey
and creates a new empty user:
TelematicsAuth.createDeviceToken(
instanceId = "<your instanceId>",
instanceKey = "<your instanceKey>")
.onSuccess { result ->
println(result.deviceToken)
println(result.accessToken)
println(result.refreshToken)
}
.onError { e ->
e.printStackTrace()
}
That's it! Now you are ready to use our authorization library.
Also you can check references in our doc.
Happy coding!
Links
Official API services web-page
Official SDK and API references
Official ZenRoad app for Android
Official ZenRoad app for Huawei
Copyright © 2020-2021 DATA MOTION PTE. LTD. All rights reserved.
Updated almost 3 years ago