Overview

This method returns a security token, which is used in all methods for authentication.

 

Syntax

[OperationContractAttribute()] 
SBT.API.DataContracts.Common.WSLoginResponse AuthenticateAPIKey( 
   SBT.API.DataContracts.Common.LoginRequestDetails loginRequest 
)

WSDL

Production: https://ui.solutionsbytext.com/Sbt.App.SetUp/WSServices/LoginAPIService.svc?singleWsdl

Staging: https://test.solutionsbytext.com/Sbt.App.SetUp/WSServices/LoginAPIService.svc?singlewsdl

 

Parameters

loginRequest

* APIKey – string (Required); APIKey generated at Tenant, Organization or Division level.

 

Return Value

WSLoginResponse
Name Type Description

Result

bool

True/False whether the call was successful or not.

ErrorCode

int

For Success/Failure it will generate error number

Message

string

Message related to the error code

SecurityToken

string

SecurityToken returned from the APIKey for API authentication purpose.

 

 

Developer Tips

In conjunction with fetching a security token, the expiration of the security token can be set to meet client enterprise security requirement(s). The following token expiration settings are provided:

  • Expire On New
  • Never Expires
  • 1 Day
  • 1 Week
  • 1 Year
  • 10 Years

Expire On New

Only one security token is live at any given time. A new token is generated when the method is invoked and the previously generated token is expired.

Never Expires

Multiple tokens can be generated and they are all live concurrently. The generated tokens do not expire.

1 Day

Multiple tokens can be generated and each respective token has a lifetime of 24 hours. If the token is referenced in an API call after the 24 hour period, an error code will be generated and returned to the client.

1 Week

Multiple tokens can be generated and each respective token has a lifetime of 1 week. If the token is referenced in an API call after the 1 week period, an error code will be generated and returned to the client.

1 Year

Multiple tokens can be generated and each respective token has a lifetime of 1 year. If the token is referenced in an API call after the 1 year period, an error code will be generated and returned to the client.

10 Years

Multiple tokens can be generated and each respective token has a lifetime of 10 years. If the token is referenced in an API call after the 10 year period, an error code will be generated and returned to the client.

 

Examples

C#

LoginAPIClient login = new LoginAPIClient("LoginAPIServiceHttpEndpoint");

  // Create loginRequestDetails
            LoginRequestDetails loginRequestDetails = new LoginRequestDetails();
            loginRequestDetails.APIKey = txtAPI.Text;

            WSLoginResponse wSLoginResponse = login.AuthenticateAPIKey(loginRequestDetails);
            txtToken.Text ="";
            //process response
            if (!wSLoginResponse.Result)
            {
                //handle error
               txtToken.Text = wSLoginResponse.Message;
            }
            else
            {
                //handle success
                txtToken.Text = wSLoginResponse.SecurityToken;
            }

 

SOAP

SOAP Request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://SBTService/ServiceContracts/" xmlns:ser1="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:dat="http://SBTAPIService/DataContract/">
   <soapenv:Header/>
   <soapenv:Body>
      <ser:AuthenticateAPIKey>
         <ser:loginRequest>
             <!--Required:-->
            <dat:APIKey>API Key</dat:APIKey>
            <!--Optional:-->
            <dat:UserName>?</dat:UserName>
            <!--Optional:-->
            <dat:Password>?</dat:Password>
         </ser:loginRequest>
      </ser:AuthenticateAPIKey>
   </soapenv:Body>
</soapenv:Envelope>

SOAP Response:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body>
      <AuthenticateAPIKeyResponse xmlns="http://SBTService/ServiceContracts/">
         <AuthenticateAPIKeyResult z:Id="i1" xmlns:a="http://SBTAPIService/DataContract/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/">
            <a:Result>true</a:Result>
            <a:ErrorCode>1400</a:ErrorCode>
            <a:Message>Successfully generated securitytoken</a:Message>
            <a:SecurityToken>Security token</a:SecurityToken>
         </AuthenticateAPIKeyResult>
      </AuthenticateAPIKeyResponse>
   </s:Body>
</s:Envelope>

 

JAVA

LoginWSService srv = new LoginWSService();		
ILoginAPI iLoginAPI = srv.getLoginAPIServiceHttpEndpoint1();
LoginRequestDetails loginRequest = newLoginRequestDetails();
JAXBElement apikey =  newJAXBElement(new QName("http://SBTAPIService/DataContract/", "APIKey"),
				new String("").getClass(),"APIKey-Text");
loginRequest.setAPIKey(apikey);
WSLoginResponse wsLoginResponse = null;
try 
{
    wsLoginResponse = iLoginAPI.authenticateAPIKey(loginRequest);
} 
catch (Throwable e) 
{			
	e.printStackTrace();
}
if(wsLoginResponse == null)
{
System.out.println("Erron while authenticating APIKey::");
return;
}             
// Process Response
if(wsLoginResponse.isResult()) 
{
	//handle success
	System.out.println("Success authenticating APIKey::"+wsLoginResponse.getMessage().getValue());
	System.out.println("Security token::"+wsLoginResponse.getSecurityToken().getValue());
} 
else
{
	//handle error
	System.out.println("Erron while authenticating APIKey::"+wsLoginResponse.getMessage());

}

 

PHP

<?php
    $client = new SoapClient("https://ui.solutionsbytext.com/Sbt.App.SetUp/WSServices/LoginAPIService.svc?wsdl");
    $param = array(
    'loginRequest' =>  array(
			'APIKey' => 'APIKey-Text'
							)
		          );
	$response = $client->__soapCall('AuthenticateAPIKey', array($param));

	if($response->AuthenticateAPIKeyResult->Result){
		echo $response->AuthenticateAPIKeyResult->Message;
		echo $response->AuthenticateAPIKeyResult->SecurityToken;
	}
	else {
		echo $response->AuthenticateAPIKeyResult->Message;
		}

?>

 

REST

Method: GET

URL: https://ui.solutionsbytext.com/SBT.App.SetUp/RSServices/LoginAPIService.svc/AuthenticateAPIKey?APIKey={APIKey}

Note: Here {APIKey} is the parameter which has to be passed to authenticate and get the security token.

Response:

The response will be in JSON format like below:

{"AuthenticateAPIKeyResult": {
   "Result": true,
   "ErrorCode": 1400,
   "Message": "Successfully generated securitytoken",
   "SecurityToken": "Some Security Token"
}}

 

Send Feedback