Registration
This feature allows the end user to register a FIDO2 authenticator with a FIDO2 server counterpart. The end user can use the registered authenticator for future authentications.
Typically, these are the steps the end user performs in a registration process from the mobile perspective:
-
The end user initiates the registration process.
-
When a FIDO2 registration payload is received, the mobile application forwards this request to Mobile FIDO SDK for further processing.
-
The end user is prompted to select the authentication mode: Passcode or Biometric. This authenticator is used to verify the end user's identity when signing in to the mobile application.
-
The end user is prompted to set the login credentials for their selected authentication mode:
-
Passcode: The end user is prompted to enter a numeric passcode.
-
Biometric: The end user is prompted for a fingerprint or face scan.
-
Mobile FIDO SDK subsequently returns a corresponding FIDO2 attestation response payload, which the mobile application returns to its corresponding FIDO2 servers.
The following sequence diagram describes the registration flow:

Tip
Mobile FIDO UI SDK is used as a means for managing the UI callbacks to the individual use cases, allowing the end user to focus on the core application logic.
Register an authenticator
To register an authenticator using the sample app:
-
On the main page, tap Register to initiate this feature.
-
You are prompted to input a username. This username can identify different FIDO registrations in the subsequent SDK versions.
If multiple authenticators are available, you are prompted to select an authenticator to verify your identity.
-
The registration process completes and the FIDO2 attestation response can then be forwarded to the respective services.

Authenticator selection
To support the selection of authenticators, app integrators need to implement the corresponding callback:
public class SampleUiCallback extends Fido2UiCallback {
@Override
public void showAuthenticators(List<Fido2AuthenticatorInfo> authenticators, final AuthenticatorSelectionCallback callback) throws Fido2Exception {
List<CharSequence> names = new ArrayList<>();
for (Fido2AuthenticatorInfo info : authenticators) {
names.add(info.getName());
}
// Display list of names or select in the app
// Callback with the selected authenticator (by index)
callback.onAuthenticatorSelected(0);
// OR cancel
callback.cancel();
}
}
class SampleUiDelegate: TGFFido2UiDelegate {
public func showAuthenticators(_ authenticatorList: [TGFFido2AuthenticatorInfo], operationInfo: TGFFido2OperationInfo, authenticatorSelectionHandler: @escaping (TGFFido2AuthenticatorInfo) -> Void, cancelHandler: @escaping () -> Void) {
let names = authenticatorList.map { $0.name }
// Display list of names or select in the app
// Callback with the selected authenticator
authenticatorSelectionHandler(authenticatorList[0])
// OR cancel
cancelHandler()
}
}
Initiate registration
The following code snippets demonstrate the usage of the register feature:
// Create Fido2 Registration request with json String
Fido2Request fido2Request = Fido2Request.jsonText(jsonString);
// Setup an instance of Fido2RespondArgs, create all required ui callback required by Mobile FIDO SDK.
Fido2UiCallback uiCallback = new SampleFido2UiCallback(activity);
PasscodeAuthenticatorCallback passcodeAuthenticatorCallback = new SamplePinPadAuthenticatorCallback(activity);
BiometricAuthenticatorCallback biometricAuthenticatorCallback = new SampleBiometricAuthenticatorCallback();
Fido2RespondArgs args = new Fido2RespondArgs.Builder()
.setFido2Request(fido2Request)
.setUiCallback(uiCallback)
.setPasscodeAuthenticatorCallback(passcodeAuthenticatorCallback)
.setBiometricAuthenticatorCallback(biometricAuthenticatorCallback)
.build();
// Create a Fido2Client
Fido2Client client = Fido2ClientFactory.createFido2Client(getApplicationContext());
client.setActivity(activity);
client.respondWithArgs(args, new Fido2ResponseCallback() {
@Override
public void onResponded(Fido2Response response) {
((SamplePinPadAuthenticatorCallback) passcodeAuthenticatorCallback).dismissPasscodeAuthenticatorDialog();
// Pass FIDO response to respective FIDO service.
}
@Override
public void onError(Fido2Exception exception) {
((SamplePinPadAuthenticatorCallback) passcodeAuthenticatorCallback).dismissPasscodeAuthenticatorDialog();
// handle error
}
}
// Create Fido2 Registration request with json String
let fidoRequest = try TGFFido2RequestFactory.request(jsonString)
// Setup an instance of TGFFido2RespondArgsBuilder,initialize all necessary UI delegates required by Mobile FIDO SDK.
let respondArgsBuilder = TGFFido2RespondArgsBuilder(request: fidoRequest, uiDelegate: clientConformer)
respondArgsBuilder.uiBiometricAuthenticatorDelegate = clientConformer
respondArgsBuilder.uiPasscodeAuthenticatorDelegate = clientConformer
respondArgsBuilder.passcodeAuthenticator = TGFPasscodeAuthenticator(delegate: clientConformer)
let respondArgs = respondArgsBuilder.respondArgs()
// Fetch a FIDO2 response.
fido2Client.respond(with: respondArgs) {(response, error) in
if let error = error {
// Handle error
} else {
let responseString: String = response!.raw()
// Pass FIDO response to respective FIDO service.
}
}
JSON string content
The expected JSON string content to be passed here MUST be the defined CredentialCreationOptions of WebAuthn.
Example of the expected JSON payload:
{
"rp": {
"name": "www.test.com",
"id": "www.test.com"
},
"user": {
"id": "d2ViYXV0aG5pby10ZXN0VXNlc1g",
"name": "testUser",
"displayName": "testUser"
},
"challenge": "hCnhko-kfy8MkUfwIDrrXZDNvZUbgxxiYg-Y5O298T4au8epmfPZ1_cIketgM0ngnioX9zqLEqr2ynWo15eQ6A",
"pubKeyCredParams": [
{
"type": "public-key",
"alg": -8
},
{
"type": "public-key",
"alg": -7
},
{
"type": "public-key",
"alg": -257
}
],
"timeout": 60000,
"excludeCredentials": [],
"authenticatorSelection": {
"residentKey": "preferred",
"requireResidentKey": false,
"userVerification": "preferred"
},
"extensions": {
},
"attestation": "direct"
}