Click or drag to resize

ServiceRouterGetToken Method

Returns a GetTokenOut result model

Namespace: AppOne.Services.V2
Assembly: AppOne.Web.Service (in AppOne.Web.Service.dll) Version: 1.0.141
Syntax
public GetTokenOut GetToken(
	GetTokenIn input
)

Parameters

input  GetTokenIn
A new GetTokenIn object

Return Value

GetTokenOut
A GetTokenOut object
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

ActionDescription
VALIDATEReturns true if the token is still valid, and returns the same AuthToken string that was passed in.
RENEWWill renew the tokens timeout limit and returns a new and different AuthToken string.
Caution note  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  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
JSON Request
{
    "AuthToken":"MkMvT2o5OWxKaFR1eU1JcDlEdTRqdz09LWV2VDRRVkVGYTRzb2lEVuYXhDZ04vNGRPS0Vl ... ==",
    "Action":"VALIDATE"
}
JSON Response
{
    "Report": {
        "ProcessTime": "0.0586418",
        "RequestTime": "/Date(1438981212236-0700)/",
        "ResponseTime": "/Date(1438981212294-0700)/",
        "Results": 1
    },
    //AuthToken property will be the same as the input when VALIDATE action is used
    //AuthToken property will be new/different when the RENEW action is used
    "Results": {
        "AuthToken": "QVhjZ1dMYWIwbDJndENRZEoyY2Uydz09LWdrb0NCVmdpTHF6T3NZZEZtWEFtd ... bXk5UA==",
        "Message": "This token is currently valid for another 1 hours 14 minutes.",
        "Success": true
    }
}
SOAP: C# WCF Sample
// ==================================
//TEST 1:  Validate
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;

// ==================================
//TEST 2: Renew
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