GET,POST | /auth/{provider} | ||
---|---|---|---|
GET,POST | /auth |
<?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};
// @DataContract
class AuthenticateResponse implements IMeta, IHasSessionId, IHasBearerToken, JsonSerializable
{
public function __construct(
// @DataMember(Order=1)
/** @var string|null */
public ?string $UserId=null,
// @DataMember(Order=2)
/** @var string|null */
public ?string $SessionId=null,
// @DataMember(Order=3)
/** @var string|null */
public ?string $UserName=null,
// @DataMember(Order=4)
/** @var string|null */
public ?string $DisplayName=null,
// @DataMember(Order=5)
/** @var string|null */
public ?string $ReferrerUrl=null,
// @DataMember(Order=6)
/** @var string|null */
public ?string $BearerToken=null,
// @DataMember(Order=7)
/** @var string|null */
public ?string $RefreshToken=null,
// @DataMember(Order=8)
/** @var DateTime|null */
public ?DateTime $RefreshTokenExpiry=null,
// @DataMember(Order=9)
/** @var string|null */
public ?string $ProfileUrl=null,
// @DataMember(Order=10)
/** @var array<string>|null */
public ?array $Roles=null,
// @DataMember(Order=11)
/** @var array<string>|null */
public ?array $Permissions=null,
// @DataMember(Order=12)
/** @var ResponseStatus|null */
public ?ResponseStatus $ResponseStatus=null,
// @DataMember(Order=13)
/** @var array<string,string>|null */
public ?array $Meta=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['UserId'])) $this->UserId = $o['UserId'];
if (isset($o['SessionId'])) $this->SessionId = $o['SessionId'];
if (isset($o['UserName'])) $this->UserName = $o['UserName'];
if (isset($o['DisplayName'])) $this->DisplayName = $o['DisplayName'];
if (isset($o['ReferrerUrl'])) $this->ReferrerUrl = $o['ReferrerUrl'];
if (isset($o['BearerToken'])) $this->BearerToken = $o['BearerToken'];
if (isset($o['RefreshToken'])) $this->RefreshToken = $o['RefreshToken'];
if (isset($o['RefreshTokenExpiry'])) $this->RefreshTokenExpiry = JsonConverters::from('DateTime', $o['RefreshTokenExpiry']);
if (isset($o['ProfileUrl'])) $this->ProfileUrl = $o['ProfileUrl'];
if (isset($o['Roles'])) $this->Roles = JsonConverters::fromArray('string', $o['Roles']);
if (isset($o['Permissions'])) $this->Permissions = JsonConverters::fromArray('string', $o['Permissions']);
if (isset($o['ResponseStatus'])) $this->ResponseStatus = JsonConverters::from('ResponseStatus', $o['ResponseStatus']);
if (isset($o['Meta'])) $this->Meta = JsonConverters::from(JsonConverters::context('Dictionary',genericArgs:['string','string']), $o['Meta']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->UserId)) $o['UserId'] = $this->UserId;
if (isset($this->SessionId)) $o['SessionId'] = $this->SessionId;
if (isset($this->UserName)) $o['UserName'] = $this->UserName;
if (isset($this->DisplayName)) $o['DisplayName'] = $this->DisplayName;
if (isset($this->ReferrerUrl)) $o['ReferrerUrl'] = $this->ReferrerUrl;
if (isset($this->BearerToken)) $o['BearerToken'] = $this->BearerToken;
if (isset($this->RefreshToken)) $o['RefreshToken'] = $this->RefreshToken;
if (isset($this->RefreshTokenExpiry)) $o['RefreshTokenExpiry'] = JsonConverters::to('DateTime', $this->RefreshTokenExpiry);
if (isset($this->ProfileUrl)) $o['ProfileUrl'] = $this->ProfileUrl;
if (isset($this->Roles)) $o['Roles'] = JsonConverters::toArray('string', $this->Roles);
if (isset($this->Permissions)) $o['Permissions'] = JsonConverters::toArray('string', $this->Permissions);
if (isset($this->ResponseStatus)) $o['ResponseStatus'] = JsonConverters::to('ResponseStatus', $this->ResponseStatus);
if (isset($this->Meta)) $o['Meta'] = JsonConverters::to(JsonConverters::context('Dictionary',genericArgs:['string','string']), $this->Meta);
return empty($o) ? new class(){} : $o;
}
}
/** @description Sign In */
// @Api(Description="Sign In")
// @DataContract
class Authenticate implements IPost, IMeta, JsonSerializable
{
public function __construct(
/** @description AuthProvider, e.g. credentials */
// @DataMember(Order=1)
/** @var string|null */
public ?string $provider=null,
// @DataMember(Order=2)
/** @var string|null */
public ?string $UserName=null,
// @DataMember(Order=3)
/** @var string|null */
public ?string $Password=null,
// @DataMember(Order=4)
/** @var bool|null */
public ?bool $RememberMe=null,
// @DataMember(Order=5)
/** @var string|null */
public ?string $AccessToken=null,
// @DataMember(Order=6)
/** @var string|null */
public ?string $AccessTokenSecret=null,
// @DataMember(Order=7)
/** @var string|null */
public ?string $ReturnUrl=null,
// @DataMember(Order=8)
/** @var string|null */
public ?string $ErrorView=null,
// @DataMember(Order=9)
/** @var array<string,string>|null */
public ?array $Meta=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['provider'])) $this->provider = $o['provider'];
if (isset($o['UserName'])) $this->UserName = $o['UserName'];
if (isset($o['Password'])) $this->Password = $o['Password'];
if (isset($o['RememberMe'])) $this->RememberMe = $o['RememberMe'];
if (isset($o['AccessToken'])) $this->AccessToken = $o['AccessToken'];
if (isset($o['AccessTokenSecret'])) $this->AccessTokenSecret = $o['AccessTokenSecret'];
if (isset($o['ReturnUrl'])) $this->ReturnUrl = $o['ReturnUrl'];
if (isset($o['ErrorView'])) $this->ErrorView = $o['ErrorView'];
if (isset($o['Meta'])) $this->Meta = JsonConverters::from(JsonConverters::context('Dictionary',genericArgs:['string','string']), $o['Meta']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->provider)) $o['provider'] = $this->provider;
if (isset($this->UserName)) $o['UserName'] = $this->UserName;
if (isset($this->Password)) $o['Password'] = $this->Password;
if (isset($this->RememberMe)) $o['RememberMe'] = $this->RememberMe;
if (isset($this->AccessToken)) $o['AccessToken'] = $this->AccessToken;
if (isset($this->AccessTokenSecret)) $o['AccessTokenSecret'] = $this->AccessTokenSecret;
if (isset($this->ReturnUrl)) $o['ReturnUrl'] = $this->ReturnUrl;
if (isset($this->ErrorView)) $o['ErrorView'] = $this->ErrorView;
if (isset($this->Meta)) $o['Meta'] = JsonConverters::to(JsonConverters::context('Dictionary',genericArgs:['string','string']), $this->Meta);
return empty($o) ? new class(){} : $o;
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /auth/{provider} HTTP/1.1
Host: initiation-pen.sirva.com
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
{
provider: String,
UserName: String,
Password: String,
RememberMe: False,
AccessToken: String,
AccessTokenSecret: String,
ReturnUrl: String,
ErrorView: String,
Meta:
{
String: String
}
}
HTTP/1.1 200 OK Content-Type: text/jsv Content-Length: length { UserId: String, SessionId: String, UserName: String, DisplayName: String, ReferrerUrl: String, BearerToken: String, RefreshToken: String, RefreshTokenExpiry: 0001-01-01, ProfileUrl: String, Roles: [ String ], Permissions: [ String ], ResponseStatus: { ErrorCode: String, Message: String, StackTrace: String, Errors: [ { ErrorCode: String, FieldName: String, Message: String, Meta: { String: String } } ], Meta: { String: String } }, Meta: { String: String } }