Class Authentication
This static class for logging into Vector and creating RobotConfiguration instances for connecting to a Vector robot.
The Login(String, String, String, String, IPAddress) method is the best way to use this class; provide all the necessary parameters and that method will retrieve the certificate, login to Anki's server, login to Vector, and return a RobotConfiguration instance that be stored and used to connect to Vector.
The remaining methods in this class can be used to retrieve each piece of connection information separately
Namespace: Anki.Vector
Assembly: Anki.Vector.dll
Syntax
public static class Authentication
  Methods
| Improve this Doc View SourceFindRobotAddress(IRobotConfiguration)
Finds the current robot address if possible or returns the address from the configuration.
public static Task<IPAddress> FindRobotAddress(this IRobotConfiguration robotConfiguration)
  Parameters
| Type | Name | Description | 
|---|---|---|
| IRobotConfiguration | robotConfiguration | The robot configuration.  | 
      
Returns
| Type | Description | 
|---|---|
| Task<IPAddress> | A task that represents the asynchronous operation; the task result contains the IP address.  | 
      
FindRobotAddress(String, Int32)
Finds the robot IP address.
public static Task<IPAddress> FindRobotAddress(string robotName, int timeout = 10000)
  Parameters
| Type | Name | Description | 
|---|---|---|
| String | robotName | Name of the robot.  | 
      
| Int32 | timeout | The timeout in milliseconds.  | 
      
Returns
| Type | Description | 
|---|---|
| Task<IPAddress> | A task that represents the asynchronous operation. The task result contains the IP address of the robot (or null if not found).  | 
      
GetCertificate(String)
Gets the certificate for the specific robot by serial number.
public static Task<string> GetCertificate(string serialNumber)
  Parameters
| Type | Name | Description | 
|---|---|---|
| String | serialNumber | The serial number.  | 
      
Returns
| Type | Description | 
|---|---|
| Task<String> | A task that represents the asynchronous operation; the task result contains the certificate.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| VectorAuthenticationException | Serial number must be provided or Serial number is not in the correct format. or Serial number is invalid. or  | 
      
GetSessionToken(String, String)
Gets the session token for the user.
public static Task<string> GetSessionToken(string emailAddress, string password)
  Parameters
| Type | Name | Description | 
|---|---|---|
| String | emailAddress | The login email address.  | 
      
| String | password | The password.  | 
      
Returns
| Type | Description | 
|---|---|
| Task<String> | A task that represents the asynchronous operation; the task result contains the session token.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| VectorAuthenticationException | Email must be provided. or Password must be provided. or Invalid email address or password. or Invalid response from Anki accounts API  | 
      
GetTokenGuid(String, String, String, IPAddress)
Gets the authentication token from the robot.
public static Task<string> GetTokenGuid(string sessionId, string certificate, string robotName, IPAddress ipAddress)
  Parameters
| Type | Name | Description | 
|---|---|---|
| String | sessionId | The session identifier.  | 
      
| String | certificate | The SSL certificate for the robot.  | 
      
| String | robotName | Name of the robot.  | 
      
| IPAddress | ipAddress | The IP address of the robot.  | 
      
Returns
| Type | Description | 
|---|---|
| Task<String> | A task that represents the asynchronous operation; the task result contains the authentication token.  | 
      
GetTokenGuid(String, String, String, String)
Gets the authentication token from the robot.
public static Task<string> GetTokenGuid(string sessionId, string certificate, string robotName, string host)
  Parameters
| Type | Name | Description | 
|---|---|---|
| String | sessionId | The session identifier.  | 
      
| String | certificate | The SSL certificate for the robot.  | 
      
| String | robotName | Name of the robot.  | 
      
| String | host | The host name or IP address with optional port.  | 
      
Returns
| Type | Description | 
|---|---|
| Task<String> | A task that represents the asynchronous operation; the task result contains the authentication token.  | 
      
Login(RobotConfiguration, String, String, IPAddress)
Updates the specified robot configuration with a new login
public static Task<RobotConfiguration> Login(RobotConfiguration robotConfiguration, string emailAddress, string password, IPAddress ipAddress = null)
  Parameters
| Type | Name | Description | 
|---|---|---|
| RobotConfiguration | robotConfiguration | The robot configuration.  | 
      
| String | emailAddress | The email address.  | 
      
| String | password | The password.  | 
      
| IPAddress | ipAddress | The IP address.  | 
      
Returns
| Type | Description | 
|---|---|
| Task<RobotConfiguration> | A task that represents the asynchronous operation; the task result the modified robot configuration parameter instance.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| VectorAuthenticationException | IP address could not be determined; please provide IP address.  | 
      
Login(String, String, String, String, IPAddress)
Performs a complete login to the robot and returns a filled in RobotConfiguration instance.
public static Task<RobotConfiguration> Login(string serialNumber, string robotName, string emailAddress, string password, IPAddress ipAddress = null)
  Parameters
| Type | Name | Description | 
|---|---|---|
| String | serialNumber | The robot serial number.  | 
      
| String | robotName | Name of the robot.  | 
      
| String | emailAddress | The user's username.  | 
      
| String | password | The user's password.  | 
      
| IPAddress | ipAddress | The optional robot IP address.  | 
      
Returns
| Type | Description | 
|---|---|
| Task<RobotConfiguration> | A task that represents the asynchronous operation; the task result contains the new robot configuration.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| ArgumentException | Serial number must be provided - serialNumber or Robot name must be provided - robotName or User name must be provided - username or Password must be provided - password or IP address could not be determined; please provide IP address. - ipAddress  | 
      
RemoteLogin(RobotConfiguration, String, String, String)
Updates the specified robot configuration with a new login
public static Task<RobotConfiguration> RemoteLogin(RobotConfiguration robotConfiguration, string emailAddress, string password, string remoteHost = null)
  Parameters
| Type | Name | Description | 
|---|---|---|
| RobotConfiguration | robotConfiguration | The robot configuration.  | 
      
| String | emailAddress | The email address.  | 
      
| String | password | The password.  | 
      
| String | remoteHost | The optional remote host to connect to (otherwise uses configured remote host).  | 
      
Returns
| Type | Description | 
|---|---|
| Task<RobotConfiguration> | A task that represents the asynchronous operation; the task result the modified robot configuration parameter instance.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | robotConfiguration  | 
      
RemoteLogin(String, String, String, String, String)
Performs a complete login to the remote robot and returns a filled in RobotConfiguration instance.
public static Task<RobotConfiguration> RemoteLogin(string serialNumber, string robotName, string emailAddress, string password, string remoteHost)
  Parameters
| Type | Name | Description | 
|---|---|---|
| String | serialNumber | The serial number.  | 
      
| String | robotName | Name of the robot.  | 
      
| String | emailAddress | The email address.  | 
      
| String | password | The password.  | 
      
| String | remoteHost | The remote host name or IP address and port.  | 
      
Returns
| Type | Description | 
|---|---|
| Task<RobotConfiguration> | A task that represents the asynchronous operation; the task result contains the new robot configuration.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| ArgumentException | Remote host cannot be empty. - remoteHost  | 
      
RobotNameIsValid(String)
Validates the name of the robot.
public static bool RobotNameIsValid(string robotName)
  Parameters
| Type | Name | Description | 
|---|---|---|
| String | robotName | Name of the robot.  | 
      
Returns
| Type | Description | 
|---|---|
| Boolean | True if the robot name is in the correct format.  | 
      
SerialNumberIsValid(String)
Validates the serial number.
public static bool SerialNumberIsValid(string serialNumber)
  Parameters
| Type | Name | Description | 
|---|---|---|
| String | serialNumber | The serial number.  | 
      
Returns
| Type | Description | 
|---|---|
| Boolean | True if the serial number is in the correct format.  | 
      
StandardizeRobotName(String)
Standardizes the name of the robot.
public static string StandardizeRobotName(string robotName)
  Parameters
| Type | Name | Description | 
|---|---|---|
| String | robotName | Name of the robot.  | 
      
Returns
| Type | Description | 
|---|---|
| String | A robot name in the correct format or the name unchanged.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| ArgumentException | Invalid robot name. Please match the format exactly. Example: Vector-A1B2 - robotName  | 
      
TryValidate(IRobotConfiguration)
Validates the specified robot configuration.
public static IEnumerable<string> TryValidate(this IRobotConfiguration robotConfiguration)
  Parameters
| Type | Name | Description | 
|---|---|---|
| IRobotConfiguration | robotConfiguration | The robot configuration.  | 
      
Returns
| Type | Description | 
|---|---|
| IEnumerable<String> | A list of errors  | 
      
Validate(IRobotConfiguration)
Validates the specified robot configuration.
public static IRobotConfiguration Validate(this IRobotConfiguration robotConfiguration)
  Parameters
| Type | Name | Description | 
|---|---|---|
| IRobotConfiguration | robotConfiguration | The robot configuration.  | 
      
Returns
| Type | Description | 
|---|---|
| IRobotConfiguration | The robot configuration unchanged.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| VectorConfigurationException | Validation error  |