Android Kotlin library for the Flow Client Library (FCL).
Report a Bug
FCL Auth Android is a Kotlin library for the Flow Client Library (FCL) that enables Flow wallet authentication on Android devices.
The example app in this project demonstrates how to use FCL inside an Android app.
You can download the latest version from the GitHub Apache Maven registry.
<dependency>
<groupId>org.onflow.fcl</groupId>
<artifactId>fcl-auth-android</artifactId>
<version>0.1.0</version>
</dependency>
You will need to configure your app information before using the authentication library.
FCL Android ships with several built-in wallet providers (Dapper, Blocto), but you can also define custom wallet providers if needed.
import org.onflow.fcl.android.auth.AppInfo
import org.onflow.fcl.android.auth.DefaultProvider
import org.onflow.fcl.android.auth.FCL
val fcl = FCL(
AppInfo(
title = "FCL Demo App",
icon = URL("https://foo.com/bar.png"),
)
)
fcl.providers.add(DefaultProvider.DAPPER)
fcl.providers.add(DefaultProvider.BLOCTO)
// use inside of an activity class
val context: android.content.Context = this
fcl.authenticate(context, DefaultProvider.DAPPER) { response ->
System.out.println(response.address)
}
The response
variable is of type AuthnResponse
, which contains the user's wallet address:
/**
* Authentication response
*
* @property [address] address of the authenticated account
* @property [status] status of the authentication (approved or declined)
* @property [reason] if authentication is declined this property will contain more description
*/
data class AuthnResponse(
val address: String?,
val status: ResponseStatus,
val reason: String?
)