| POST | /api/authentication/token | Get Bearer access token, contact support for credentials |
|---|
<?php namespace dtos;
use DateTime;
use Exception;
use DateInterval;
use JsonSerializable;
use ServiceStack\{IReturn,IReturnVoid,IGet,IPost,IPut,IDelete,IPatch,IMeta,IHasSessionId,IHasBearerToken,IHasVersion};
use ServiceStack\{ICrud,ICreateDb,IUpdateDb,IPatchDb,IDeleteDb,ISaveDb,AuditBase,QueryDb,QueryDb2,QueryData,QueryData2,QueryResponse};
use ServiceStack\{ResponseStatus,ResponseError,EmptyResponse,IdResponse,ArrayList,KeyValuePair2,StringResponse,StringsResponse,Tuple2,Tuple3,ByteArray};
use ServiceStack\{JsonConverters,Returns,TypeContext};
class AccessTokenResponse implements JsonSerializable
{
public function __construct(
/** @var string */
public string $accessToken='',
/** @var string */
public string $scope='',
/** @var string */
public string $tokenType='',
/** @var int */
public int $expiresIn=0,
/** @var int */
public int $httpStatusCode=0,
/** @var string */
public string $httpErrorReason='',
/** @var string */
public string $error=''
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['accessToken'])) $this->accessToken = $o['accessToken'];
if (isset($o['scope'])) $this->scope = $o['scope'];
if (isset($o['tokenType'])) $this->tokenType = $o['tokenType'];
if (isset($o['expiresIn'])) $this->expiresIn = $o['expiresIn'];
if (isset($o['httpStatusCode'])) $this->httpStatusCode = $o['httpStatusCode'];
if (isset($o['httpErrorReason'])) $this->httpErrorReason = $o['httpErrorReason'];
if (isset($o['error'])) $this->error = $o['error'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->accessToken)) $o['accessToken'] = $this->accessToken;
if (isset($this->scope)) $o['scope'] = $this->scope;
if (isset($this->tokenType)) $o['tokenType'] = $this->tokenType;
if (isset($this->expiresIn)) $o['expiresIn'] = $this->expiresIn;
if (isset($this->httpStatusCode)) $o['httpStatusCode'] = $this->httpStatusCode;
if (isset($this->httpErrorReason)) $o['httpErrorReason'] = $this->httpErrorReason;
if (isset($this->error)) $o['error'] = $this->error;
return empty($o) ? new class(){} : $o;
}
}
/** @description Auth */
// @Api(Description="Auth")
// @ApiResponse(Description="Access token response", IsDefaultResponse=true, StatusCode=200)
class GetAuthToken implements JsonSerializable
{
public function __construct(
/** @description Post parameters in body */
// @ApiMember(Description="Post parameters in body", ParameterType="model")
/** @var string */
public string $clientId='',
/** @description Post parameters in body */
// @ApiMember(Description="Post parameters in body", ParameterType="model")
/** @var string */
public string $clientSecret='',
/** @description Post parameters in body */
// @ApiMember(Description="Post parameters in body", ParameterType="model")
/** @var string */
public string $scope=''
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['clientId'])) $this->clientId = $o['clientId'];
if (isset($o['clientSecret'])) $this->clientSecret = $o['clientSecret'];
if (isset($o['scope'])) $this->scope = $o['scope'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->clientId)) $o['clientId'] = $this->clientId;
if (isset($this->clientSecret)) $o['clientSecret'] = $this->clientSecret;
if (isset($this->scope)) $o['scope'] = $this->scope;
return empty($o) ? new class(){} : $o;
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /api/authentication/token HTTP/1.1
Host: stf-api-uat.data-xchange.co.za
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<GetAuthToken xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/DX.STF.Application.ClientApi.Messages.Authentication">
<ClientId>String</ClientId>
<ClientSecret>String</ClientSecret>
<Scope>String</Scope>
</GetAuthToken>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <AccessTokenResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/DX.STF.Application.ClientApi.ResponseMessages.Authentication"> <AccessToken>String</AccessToken> <Error>String</Error> <ExpiresIn>0</ExpiresIn> <HttpErrorReason>String</HttpErrorReason> <HttpStatusCode>0</HttpStatusCode> <Scope>String</Scope> <TokenType>String</TokenType> </AccessTokenResponse>