https://github.com/onflow/fcl-auth-android
A Kotlin library for the Flow Client Library (FCL) that enables Flow wallet authentication on Android devices
https://github.com/onflow/fcl-auth-android
Last synced: 5 months ago
JSON representation
A Kotlin library for the Flow Client Library (FCL) that enables Flow wallet authentication on Android devices
- Host: GitHub
- URL: https://github.com/onflow/fcl-auth-android
- Owner: onflow
- Created: 2021-09-24T07:39:39.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-09-28T19:57:16.000Z (about 4 years ago)
- Last Synced: 2025-04-05T04:11:14.686Z (8 months ago)
- Language: Kotlin
- Homepage:
- Size: 770 KB
- Stars: 2
- Watchers: 7
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
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)](https://docs.onflow.org/fcl/)
that enables Flow wallet authentication on Android devices.
## Demo
The [example app](/example) in this project demonstrates how to use FCL inside an Android app.

## Installation
You can download the latest version from the [GitHub Apache Maven registry](https://github.com/onflow/fcl-android/packages).
```xml
org.onflow.fcl
fcl-auth-android
0.1.0
```
- [How to install with Maven](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry#installing-a-package)
- [How to install with Gradle](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-gradle-registry#using-a-published-package)
## Configuration
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.
```kotlin
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)
```
## Authenticate
```kotlin
// 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:
```kotlin
/**
* 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?
)
```