createToken method

Future<AppCheckToken> createToken(
  1. String appId, [
  2. AppCheckTokenOptions? options
])

Creates a new AppCheckToken that can be sent back to a client.

appId - The app ID to use as the JWT app_id. options - Optional options object when creating a new App Check Token.

Returns a future that fulfills with a AppCheckToken.

Implementation

Future<AppCheckToken> createToken(
  String appId, [
  AppCheckTokenOptions? options,
]) async {
  if (appId.isEmpty) {
    throw FirebaseAppCheckException(
      AppCheckErrorCode.invalidArgument,
      '`appId` must be a non-empty string.',
    );
  }

  final customToken = await _tokenGenerator.createCustomToken(appId, options);

  return _requestHandler.exchangeToken(customToken, appId);
}