# JWT signing

Keyelss mobile SDK can generate a signed a JWT containing a custom payload. You can use the signed JWT to implement [Dynamic Linking](https://docs.keyless.io/consumer/mobile-sdk-use-cases/guide-sca-dynamic-linking).

## Generate signed JWT

Pass `JwtSigningInfo` to the authentication to generate a signed JWT:

{% tabs %}
{% tab title="Android" %}

```kotlin
//Keyless adds a td claim to the JWTs containing the data you specify
val jwtSigningInfo = JwtSigningInfo(claimTransactionData = "<your custom data")

// if you want to authenticate with biometric
val biomAuthConfig = BiomAuthConfig(jwtSigningInfo = jwtSigningInfo)
// if you want to authenticate with pin
val pinAuthConfig = PinAuthConfig(pin = "1234", jwtSigningInfo = jwtSigningInfo)

// perform the authentication
Keyless.authenticate(
    configuration = biomAuthConfig, // pinAuthConfig if you use pin
    onCompletion = { /*TODO: process result*/ }
)
```

{% endtab %}

{% tab title="iOS" %}

```swift
//Keyless adds a td claim to the JWTs containing the data you specify
let jwtSigningInfo = JwtSigningInfo(claimTransactionData: "<your custom data>")

// if you want to authenticate with biometric
let biomAuthConfig = BiomAuthConfig(jwtSigningInfo: jwtSigningInfo)
// if you want to authenticate with pin
let pinAuthConfig = PinAuthConfig(pin: "1234", jwtSigningInfo: jwtSigningInfo)

// perform the authentication
Keyless.authenticate(
    configuration: biomAuthConfig, // pinAuthConfig if you use pin
    onCompletion : { /*TODO: process result*/ }
)
```

{% endtab %}

{% tab title="Flutter" %}

```dart
import 'package:keyless_flutter_sdk/keyless.dart';
import 'package:keyless_flutter_sdk/models/jwt_signing_info.dart';
import 'package:keyless_flutter_sdk/models/configurations/authentication_configuration.dart';

// Keyless adds a td claim to the JWTs containing the data you specify
final jwtSigningInfo = JwtSigningInfo("<your custom data>");

// if you want to authenticate with biometric
final biomAuthConfig = BiomAuthConfig(
    jwtSigningInfo: jwtSigningInfo
);

// if you want to authenticate with pin
final pinAuthConfig = PinAuthConfig(
    pin: "1234",
    jwtSigningInfo: jwtSigningInfo
);

try {
    // perform the authentication with either biometric or pin config
    final result = await Keyless.instance.authenticate(
        biomAuthConfig // or pinAuthConfig if you use pin
    );
    print("JWT signed successfully: ${result.signedJwt}");
} catch (error) {
    print("Authentication failed: $error");
}
```

{% endtab %}

{% tab title="React Native" %}

```typescript
    // Keyless adds a td claim to the JWTs containing the data you specify
    const jwtSigningInfo = new JwtSigningInfo('<your custom data>');

    // if you want to authenticate with biometric
    const biomAuthConfig = new BiomAuthConfig({
      jwtSigningInfo: jwtSigningInfo,
    });
    // if you want to authenticate with pin
    const pinAuthConfig = new PinAuthConfig({
      pin: '1234',
      jwtSigningInfo: jwtSigningInfo,
    });

    const result = await Keyless.authenticate(
      biomAuthConfig // or pinAuthConfig if you use pin
    );

    result.fold({
      onSuccess(data) {
        logConsole('Auth result success ' + JSON.stringify(data, null, 2));
      },
      onFailure(error) {
        logConsole('Auth result failure ' + JSON.stringify(error, null, 2));
      },
    });
```

{% endtab %}
{% endtabs %}

## User signing public key

The AuthenticationSuccess contains the following fields:

* `signedJwt`: the signed JWT.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.keyless.io/consumer/mobile-sdk-reference/jwt-signing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
