Table of Contents

Class Credentials

Namespace
Vonage.Request
Assembly
Vonage.dll

Represents credentials for Vonage APIs.

public class Credentials
Inheritance
Credentials
Inherited Members

Properties

ApiKey

Vonage API Key (from your account dashboard)

public string ApiKey { get; }

Property Value

string

ApiSecret

Vonage API Secret (from your account dashboard)

public string ApiSecret { get; }

Property Value

string

AppUserAgent

(Optional) App useragent value to pass with every request

public string AppUserAgent { get; }

Property Value

string

ApplicationId

Application ID (GUID)

public string ApplicationId { get; }

Property Value

string

ApplicationKey

Application private key contents This is the actual key file contents and NOT a path to the key file!

public string ApplicationKey { get; }

Property Value

string

Method

Method to be used for signing SMS Messages

public SmsSignatureGenerator.Method Method { get; }

Property Value

SmsSignatureGenerator.Method

SecuritySecret

Signature Secret (from API settings section of your account settings)

public string SecuritySecret { get; }

Property Value

string

Methods

FromApiKeyAndSecret(string, string)

Builds credentials from ApiKey and ApiSecret.

public static Credentials FromApiKeyAndSecret(string apiKey, string apiSecret)

Parameters

apiKey string

The api key.

apiSecret string

The api secret.

Returns

Credentials

The credentials.

FromApiKeySignatureSecretAndMethod(string, string, Method)

Builds Credentials from ApiKey, SignatureSecret and Method.

public static Credentials FromApiKeySignatureSecretAndMethod(string apiKey, string signatureSecret, SmsSignatureGenerator.Method signatureMethod)

Parameters

apiKey string

The api key.

signatureSecret string

The signature secret.

signatureMethod SmsSignatureGenerator.Method

The signature method.

Returns

Credentials

The credentials.

FromAppIdAndPrivateKey(string, string)

Builds Credentials from ApplicationId and PrivateKey.

public static Credentials FromAppIdAndPrivateKey(string appId, string privateKey)

Parameters

appId string

The application id.

privateKey string

The private key.

Returns

Credentials

The credentials.

FromAppIdAndPrivateKeyPath(string, string)

Builds Credentials from ApplicationId and PrivateKey file.

public static Credentials FromAppIdAndPrivateKeyPath(string appId, string privateKeyPath)

Parameters

appId string

Your Vonage Application ID

privateKeyPath string

path to your private Key file

Returns

Credentials

CredentialsObject

Exceptions

UnauthorizedAccessException

Thrown if app doesn't have required permission to key file

ArgumentException

privateKeyPath is a zero length string, contains only white space or contains one or more invalid characters

ArgumentNullException

privateKeyPath is null

PathTooLongException

The specified path, filename, or both exceed the system-defined max length

DirectoryNotFoundException

The specified path is invalid, (for example, it is on an unmapped drive).

FileNotFoundException

The file specified in path was not found.

NotSupportedException

path is in an invalid format.

GetAuthenticationHeader()

Provides the preferred authentication based on authentication type.

public Result<AuthenticationHeaderValue> GetAuthenticationHeader()

Returns

Result<AuthenticationHeaderValue>

The authentication header if it matches any criteria. A AuthenticationFailure otherwise.

GetPreferredAuthenticationType()

Provides the preferred authentication type.

public Result<AuthType> GetPreferredAuthenticationType()

Returns

Result<AuthType>

The authentication type if it matches any criteria. A AuthenticationFailure otherwise.

Remarks

Bearer will always be preferred over Basic if possible.

GetUserAgent()

Returns the user agent from credentials if not null, from configuration otherwise.

public string GetUserAgent()

Returns

string

The user agent.