Can we login our Android Kotlin app by serial number?

Hi, We now authenticate our devices by scanning a QR code and let user login. See this flow:

But we have some IoT unique devices without screen. So we like to auto login them with their serial numbers? Is their some documentation how to do that?

If we can for example hardcode the username and password securely in the code. (something like this):

authentication
    .login("companyId@placeholder-email.com", "serial number")
    .setScope("openid email profile offline_access")
    .start(object : Callback<Credentials, AuthenticationException> {
        override fun onFailure(exception: AuthenticationException) {
            // Error
        }

        override fun onSuccess(credentials: Credentials) {
            //Save the credentials
            manager.saveCredentials(credentials)
        }
    })

We can easy create a user with:

Trough our backend. Then if we provision a device, we can set create this user, with linked serialnumber to auto login.

If we need to remove access, we can easy remove the user from Auth0.

Hope their are some tips how to handle this. Since in all documentation I only see options with the Auth0 login form to login.

Hi @flip,

Thanks for your question.

I don’t believe there is any way to log in to your app using only the serial number.
As an alternative option, you could try logging the user in with their email/password using the password grant flow.

In the Auth0 Android SDK, there is a the login() function that allows you to accomplish this:

fun login(
    usernameOrEmail: String, 
    password: String
): AuthenticationRequest

(Reference: index for package auth0.com.auth0.android.authentication.-authentication-a-p-i-client - auth0 3.5.0 javadoc)

Let me know if you have any follow-up questions.

Thanks,
Rueben

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.