Full integration¶
Here you will learn how to integrate Alice Onboarding in your backend to automate the onboarding of your clients. Your backend will be in charge of managing authentications and all kinds of user-related operations.
See also
To obtain the API_KEY
please check your credentials or contact support.es@alicebiometrics.com
The following diagram explains the authentication flow.
Authentication flow¶

Get your
API_KEY
provided within your credentials.Your backend gets a
LOGIN_TOKEN
from the Alice Onboarding service using yourAPI_KEY
.curl --request GET \ --url https://apis.alicebiometrics.com/onboarding/login_token \ --header 'apikey: <YOUR-API-KEY>'
Go directly to the next step
Your backend asks for a
BACKEND_TOKEN
using theLOGIN_TOKEN
.curl --request GET \ --url https://apis.alicebiometrics.com/onboarding/backend_token \ --header 'Authorization: Bearer <LOGIN_TOKEN>'
from alice import Auth, Config, Onboarding config = Config(api_key="<YOUR-API-KEY>") auth = Auth.from_config(config) backend_token = auth.create_backend_token().unwrap_or_throw()
Using the
BACKEND_TOKEN
, your backend creates a new user on the onboarding service. This is a must before starting the onboarding flow.curl --request POST \ --url https://apis.alicebiometrics.com/onboarding/user \ --header 'Authorization: Bearer <BACKEND_TOKEN>' \ --header 'Content-Type: multipart/form-data' \ --form email=example@example.com
onboarding = Onboarding.from_config(config) user_id = onboarding.create_user().unwrap_or_throw()
Using both the
user_id
andLOGIN_TOKEN
, your backend asks for aUSER_TOKEN
.curl --request GET \ --url https://apis.alicebiometrics.com/onboarding/user_token/<user_id> \ --header 'Authorization: Bearer <LOGIN_TOKEN>'
user_token = auth.create_user_token(user_id=user_id).unwrap_or_throw()
Your app receives the
USER_TOKEN
from your backend and injects the token into our client SDK. Now the client-side SDK is ready to operate against the Alice Onboarding API.The client SDK uses the
USER_TOKEN
to upload selfies, documents, and other user operations.
In-App authenticator¶
For every client-side SDK, we provide you an in-app authenticator so you can standardize the way you pass the USER_TOKEN
into our SDK.
Please check the following table and code snippets.
SDK |
|
---|---|
iOS |
Implement the |
Android |
Implement the |
React Native |
Add our React Native component to your application |
HTML + JS |
Implement the |
class MyBackendAuthenticator : Authenticator {
func execute(completion: @escaping Response<String, AuthenticationError>){
// Add here your code to retrieve the user token from your backend
let userToken = "fakeUserToken"
completion(.success(userToken))
}
}
let authenticator = MyBackendAuthenticator()
authenticator.execute { result in
switch result {
case .success(let userToken):
// Configure Alice Onboarding with the OnboardingConfig
// Then Run the Alice Onboarding Flow
case .failure(let error):
// Inform the user about Authentication Errors
}
}
class MyBackendAuthenticator : Authenticator {
override fun execute(callback: (Response) -> Unit) {
// Add here your code to retrieve the user token from your backend
val userToken = "fakeUserToken"
callback(Response.Success(userToken))
}
}
val authenticator = MyBackendAuthenticator()
authenticator.execute { response ->
when (response) {
is Response.Success -> {
// Configure Alice Onboarding with the OnboardingConfig
// Then Run the Alice Onboarding Flow
}
is Response.Failure -> {
// Inform the user about Authentication Errors
}
}
}
<Onboarding
userToken={this.getUserTokenFromMyBackend()}
config={ONBOARDING_CONFIG}
onSuccess={(userStatusJson) => console.log("onSuccess:" + userStatusJson) }
onFailure={(failureJson) => console.log("onFailure:" + failureJson) }
onCancel={(value) => console.log("onCancel:" + value) }
/>
class MyBackendAuthenticator extends aliceonboarding.Authenticator {
constructor() {
super();
}
execute() {
return new Promise((resolve, reject) => {
// Add here your code to retrieve the user token from your backend
let userToken = "fakeUserToken";
resolve(userToken);
});
}
}
let authenticator = MyBackendAuthenticator()
authenticator.execute()
.then( userToken => {
// Configure Alice Onboarding with the OnboardingConfig
// Then, Run the Alice Onboarding Flow
})
.catch( error => {
// Inform the user about Authentication Errors
});
See also
For more details and examples about the In-App authenticators please check the corresponding Authentication sections of each client-side SDK.