Click or drag to resize

IJsonPostWsBackupGetUserAuthenticationToken Method

This method returns the user authentication token requested by the rest requests.

Namespace:  Aruba.Cloud.WsBackup
Assembly:  Aruba.Cloud.WsBackup (in Aruba.Cloud.WsBackup.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
[OperationContractAttribute]
[WebInvokeAttribute(Method = "POST", ResponseFormat = WebMessageFormat.Json)]
Stream GetUserAuthenticationToken(
	GetUserAuthenticationTokenRequest request
)

Parameters

request
Type: GetUserAuthenticationTokenRequest

Return Value

Type: Stream
User authentication token
Examples
Each user is associated with a unique token, valid for 30 minutes, that certifies that the service has been authenticated. If you have a valid token you can make calls to WSEndUser methods. After each call to any Aruba WSEndUser method the service actually checks for an invalid token for the account specified. If this does not exist, or if the token has expired, you will need to authenticate it again to get it. In reality, the token is a substitute for password that has a temporary validity. The APIs are authenticated with the pair username + password or username+valid token. Getting the token for to recall the APIs is not mandatory. The GetUserAuthenticationToken (WsCommon) and GetUserAuthenticationToken (WsEndUser) methods cannot be called with the username + token for security reasons. The example generates an authentication token and associates it with the account indicated.
//IWsEndUser.GetUserAuthenticationToken Method (c# .NET) 
private static void LoginToAccount(WsEndUserClient client)
{
    //specifies the account login details
    client.ClientCredentials.UserName.UserName = "ARU-0000";
    client.ClientCredentials.UserName.Password = "0123456789";
    try
    {
        WsResultOfUserToken result = client.GetUserAuthenticationToken();

        if (result.Success)
        {
            //the method was successful
        }
        else
        {
            throw new Exception(result.ResultMessage);
        }
    }
    catch (MessageSecurityException msEx)
    {
        //user not authenticated 
        throw new Exception(msEx.Message);
    }
    catch (Exception ex)
    {
        //generic exception
        throw new Exception(ex.Message);
    }
}
See Also