Quickstart sample for the Android FIDO API
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.


Android FIDO U2F API Sample

A basic app showing how to register and authenticate FIDO U2F Security Keys using the FIDO U2F API.

FIDO U2F API is used for devices running Android L (API level 21) or newer.


The Fast Identity Online Universal 2nd Factor (FIDO U2F) API is now available. It provides U2F physical security key support to apps, in accordance with the standards defined by the FIDO Alliance.

This API should be accessed from U2fApiClient entry point. For example, here is how to get an instance of it:

private U2fApiClient mU2fApiClient;
mU2fApiClient = Fido.getU2fApiClient(this /* calling activity */);

U2fPendingIntent can be used to launch U2F request. Here are different ways for registration and sign respectively to get a U2fPendingIntent from the entry point. For a registration request:

Task<U2fPendingIntent> result =

For a sign request:

Task<U2fPendingIntent> result =

launchPendingintent(Activity, int) can be used to launch the U2F request.

     new OnSuccessListener<U2fPendingIntent>() {
       public void onSuccess(U2fPendingIntent u2fPendingIntent) {
         if (u2fPendingIntent.hasPendingIntent()) {
           // Start a U2F registration request.
           u2fPendingIntent.launchPendingIntent(this, REGISTER_REQUEST_CODE);
           // For a U2F sign request.
           // u2fPendingIntent.launchPendingIntent(this, SIGN_REQUEST_CODE);

     new OnFailureListener() {
       public void onFailure(Exception e) {
           // fail

Handling the result:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  if (resultCode != RESULT_OK) {
    // Something went wrong

  switch(requestCode) {
      RegisterResponseData registerResponse = (RegisterResponseData) data
      // Do something useful
      SignResponseData signResponse = (SignResponseData) data
      // Do something useful
      // Something went wrong


  • Android SDK 26
  • Android Build Tools v25.0.3
  • Android Support Repository

Getting Started

To install the sample app on your Android device or emulator, run ./gradlew :app:installRelease. This will install the release configuration, which uses the bundled keystore file to make the app work with the demo server.


If you've found an error in this sample, please file an issue: https://github.com/googlesamples/android-fido

Patches are encouraged, and may be submitted by forking this project and submitting a pull request through GitHub. Please see CONTRIBUTING.md for more details.


Copyright 2017 Google Inc. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at


Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.