getSetupUri method

Uri getSetupUri({
  1. required String appName,
  2. String? accountName,
})

Gets the URI for setting up an authenticator app which can be used to render a QR code or create a button which opens the user's authenticator app.

You must pass your application's name which will be used as a label in the authenticator app. Optionally, pass an accountName which will be set to the user's username by default.

Implementation

Uri getSetupUri({
  required String appName,
  String? accountName,
}) =>
    Uri(
      scheme: 'otpauth',
      host: 'totp',
      path: '/$appName:${accountName ?? _username}',
      query: _encodeQueryParameters({
        'secret': sharedSecret,
        'issuer': appName,
      }),
    );