ServiceRouterGetToken Method | |
Namespace: AppOne.Services.V2Assembly: AppOne.Web.Service (in AppOne.Web.Service.dll) Version: 1.0.141
Syntax Remarks
Returns a
GetTokenOut result model. The method works in conjunction with the
CreateToken(CreateTokenIn)
method. The Base64 encoded string that is returned from the CreateToken method is the required AuthToken property used to validate if the current token is valid or if the token can be renewed.
Action Types
Action | Description |
---|
VALIDATE | Returns true if the token is still valid, and returns the same AuthToken string that was passed in. |
RENEW | Will renew the tokens timeout limit and returns a new and different AuthToken string. |
Caution |
---|
Once a token has expired it can never be renewed or used again. When the RENEW action is used it will create a new and different AuthToken string in the response. When the VALIDATE action is used
it will return the same AuthToken that was passed in. The original AuthToken string that was used with the CreateToken(CreateTokenIn) method will only be valid
for a MAX of two hours, after that point the string is no longer valid.
|
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 {
"AuthToken":"MkMvT2o5OWxKaFR1eU1JcDlEdTRqdz09LWV2VDRRVkVGYTRzb2lEVuYXhDZ04vNGRPS0Vl ... ==",
"Action":"VALIDATE"
}
{
"Report": {
"ProcessTime": "0.0586418",
"RequestTime": "/Date(1438981212236-0700)/",
"ResponseTime": "/Date(1438981212294-0700)/",
"Results": 1
},
"Results": {
"AuthToken": "QVhjZ1dMYWIwbDJndENRZEoyY2Uydz09LWdrb0NCVmdpTHF6T3NZZEZtWEFtd ... bXk5UA==",
"Message": "This token is currently valid for another 1 hours 14 minutes.",
"Success": true
}
}
int countTest_1 = 0;
SoapServiceV2.GetTokenRequest request1 = new SoapServiceV2.GetTokenRequest();
request1.input = new SoapServiceV2.GetTokenIn
{
Action = "VALIDATE",
AuthToken = ""
};
SoapServiceV2.GetTokenResponse response1 = client.GetToken(request1);
countTest_1 = (response1.GetTokenResult.Results.Success) ? 1 : 0;
int countTest_2 = 0;
SoapServiceV2.GetTokenRequest request2 = new SoapServiceV2.GetTokenRequest();
request2.input = new SoapServiceV2.GetTokenIn
{
Action = "RENEW",
AuthToken = ""
};
SoapServiceV2.GetTokenResponse response2 = client.GetToken(request2);
countTest_2 = (response1.GetTokenResult.Results.Success) ? 1 : 0;
Assert.IsTrue(countTest_2 > 0 && countTest_1 > 0);
See Also