AddCredential Method
AddCredential(Credential)
Adds a new credential or overwrites the existing one on the YubiKey.
public void AddCredential(Credential credential)
Parameters
Type | Name | Description |
---|---|---|
Credential | credential | The Credential to add to the YubiKey. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Provided credential is null. |
System.InvalidOperationException | There is no |
System.Security.SecurityException | Unable to verify password either because |
AddCredential(String, String, CredentialType, CredentialPeriod)
Adds a new credential or overwrites the existing one on the YubiKey with default parameters.
public Credential AddCredential(string issuer, string account, CredentialType type, CredentialPeriod period)
Parameters
Type | Name | Description |
---|---|---|
System.String | issuer | The issuer is an optional string indicating the provider or service. |
System.String | account | The account name that usually is the user's email address. |
CredentialType | type | Indicates the CredentialType of the credential as either HOTP or TOTP. The default value is TOTP. |
CredentialPeriod | period | Indicates the CredentialPeriod of the credential in seconds for TOTP code. It can only be 15, 30, or 60 seconds. For HOTP should be set to zero (Undefined). The default value is 30. |
Returns
The Credential that was created and added to the YubiKey.
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | There is no |
System.Security.SecurityException | Unable to verify password either because |
Remarks
If type and period properties are not modified, this will add a TOTP credential with default parameters like: Type - TOTP, Period - 30 seconds, Algorithm - SHA-1, Digits - 6, No secret, No touch.
AddCredential(String)
Adds a credential from the string that received from the QR reader or manually from the server.
public Credential AddCredential(string stringFromURI)
Parameters
Type | Name | Description |
---|---|---|
System.String | stringFromURI | The string that received from the QR reader or manually from the server. |
Returns
The Credential that was created and added to the YubiKey.
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Provided string is null, empty, or consists only of white-space characters. |
System.InvalidOperationException | There is no |
System.Security.SecurityException | Unable to verify password either because |
Remarks
This method parses an 'otpauth://' Uri string that received from the QR reader or manually from the server, as specified by https://github.com/google/google-authenticator/wiki/Key-Uri-Format