Click or drag to resize

BaseServiceCreateToken Method

Returns a brand new token used for service authentication

Namespace: AppOne.Services.V2
Assembly: AppOne.Web.Service (in AppOne.Web.Service.dll) Version: 1.0.141
Syntax
public string CreateToken(
	CreateTokenIn request
)

Parameters

request  CreateTokenIn
A new valid CreateTokenIn object

Return Value

String
A base64 encoded string that varies in length from 255-300 characters
Remarks
Use this method to create a token. A token is required to perform any action or service request. The input name for most tokens is 'AuthToken' and can passed as an input in the payload or part of the query string.

Note  Note
A token return string will live for about 2 hours once created. After that the token will expire and a new one will need to be created. This method is very lightweight and can be called before each request if needed to ensure a token is never stale, however it is recommend that you try to reuse the generated token in your work-flow if possible.
Caution note  Caution
It is recommend to always validate a token via the GetToken(GetTokenIn) method before sending a request. Sending in an invalid token will result in an error.
Note  Note
Using the GetToken(GetTokenIn) method with the RENEW action is much quicker than calling a CreateToken(CreateTokenIn) method request. If you work with a large pool of web service requests its better to use the CreateToken method once for the initial creation process and then use a series GetToken RENEW calls to get your token.
Example
//SOAP EXAMPLE CALL
//Create generic token wrapper method
public string CreateToken()
{

    string tokenKey;
    SoapService.CreateToken createToken = new SoapService.CreateToken {
        CustomerAlias = "MyCustomerAlias", 
        UserName = "MyUserName",
        UserPass = "MyUserPass",
        SharedKey = "MyBrandSharedKey"
    };

    SoapService.CreateTokenRequest request = new SoapService.CreateTokenRequest(createToken);
    using (SoapService.ServiceRouterClient client = new SoapService.ServiceRouterClient())
    {
        SoapService.CreateTokenResponse response = client.CreateToken(request);
        tokenKey = response.CreateTokenResult;
    }

    return tokenKey;
}

var AuthToken = MyClass.CreateToken();
See Also