---
name: "URI::otpauth"
section: "3pm"
platform: "linux"
package: "perl-uri"
version: "5.40-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/URI::otpauth"
---

# URI::otpauth(3pm)

URI scheme for secret keys for OTP secrets. Usually found in QR codes

## NAME

URI::otpauth - URI scheme for secret keys for OTP secrets.  Usually found in QR codes

## VERSION

Version 5.29

## SYNOPSIS

```
  use URI;
  # optauth URI from textual uri
  my $uri = URI->new( 'otpauth://totp/Example:alice@google.com?secret=NFZS25DINFZV643VOAZXELLTGNRXEM3UH4&issuer=Example' );
  # same URI but created from arguments
  my $uri = URI::otpauth->new( type => 'totp', issuer => 'Example', account_name => 'alice@google.com', secret => 'is-this_sup3r-s3cr3t?' );
```

## DESCRIPTION

This URI scheme is defined in \<https://github.com/google/google-authenticator/wiki/Key-Uri-Format/\>:

## SUBROUTINES/METHODS

### "new"

Create a new URI::otpauth. The available arguments are listed below;

- •

  account\_name - this can be the account name (probably an email address) used when authenticating with this secret.  It is an optional field.

- •

  algorithm - this is the cryptographic hash function \<https://en.wikipedia.org/wiki/Cryptographic\_hash\_function\> that should be used.  Current values are SHA1 \<https://en.wikipedia.org/wiki/SHA-1\>, SHA256 \<https://en.wikipedia.org/wiki/SHA-2\> or SHA512 \<https://en.wikipedia.org/wiki/SHA-2\>.  It is an optional field and will default to SHA1.

- •

  counter - this is only required when the type is HOTP.

- •

  digits - this determines the length \<https://github.com/google/google-authenticator/wiki/Key-Uri-Format/#digits\> of the code presented to the user.  It is an optional field and will default to 6 digits.

- •

  issuer - this can be the application / system \<https://github.com/google/google-authenticator/wiki/Key-Uri-Format/#issuer\> that this secret can be used to authenticate to.  It is an optional field.

- •

  label - this is the issuer and the account name \<https://github.com/google/google-authenticator/wiki/Key-Uri-Format/#label\> joined with a ":" character.  It is an optional field.

- •

  period - this is the period that the TOTP code is valid for \<https://github.com/google/google-authenticator/wiki/Key-Uri-Format/#counter\>.  It is an optional field and will default to 30 seconds.

- •

  secret - this is the key \<https://en.wikipedia.org/wiki/Key\_(cryptography)\> that the TOTP \<https://en.wikipedia.org/wiki/Time-based\_one-time\_password\>/HOTP \<https://en.wikipedia.org/wiki/HMAC-based\_one-time\_password\> algorithm uses to derive the value.  It is an arbitrary byte string and must remain private.  This field is mandatory.

- •

  type - this can be 'hotp \<https://en.wikipedia.org/wiki/HMAC-based\_one-time\_password\>' or 'totp \<https://en.wikipedia.org/wiki/Time-based\_one-time\_password\>'.  This field will default to 'totp'.

### "algorithm"

Get or set the algorithm of this otpauth URI.

### "account\_name"

Get or set the account\_name of this otpauth URI.

### "counter"

Get or set the counter of this otpauth URI.

### "digits"

Get or set the digits of this otpauth URI.

### "issuer"

Get or set the issuer of this otpauth URI.

### "label"

Get or set the label of this otpauth URI.

### "period"

Get or set the period of this otpauth URI.

### "secret"

Get or set the secret of this otpauth URI.

### "type"

Get or set the type of this otpauth URI.

```
  my $type = $uri->type('hotp');
```

## CONFIGURATION AND ENVIRONMENT

URI::otpauth requires no configuration files or environment variables.

## DEPENDENCIES

URI

## DIAGNOSTICS

- "secret is a mandatory parameter for URI::otpauth"

  The secret parameter was not detected for the URI::otpauth-\>**new()** method.

## INCOMPATIBILITIES

None reported.

## BUGS AND LIMITATIONS

To report a bug, or view the current list of bugs, please visit \<https://github.com/libwww-perl/URI/issues\>

## AUTHOR

David Dick `"<ddick@cpan.org>"`

## LICENSE AND COPYRIGHT

Copyright (c) 2024, David Dick `"<ddick@cpan.org>"`.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
