Difference between revisions of "AOTG API Authenticate"

From AutoCount Resource Center
Jump to navigation Jump to search
(Created page with " ==DRAFT== Obtain '''AccessToken''' from AOTG Cloud Server is required to gain access to AOTG API. The '''AccessToken''' has an expiry date and time.<br/> Which means progra...")
 
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
  +
{{AOTGApiMethodsSpec|POST|/api/public/v1/TokenAuth/Authenticate}}
   
  +
<br/>
==DRAFT==
 
  +
==Description==
 
 
Obtain '''AccessToken''' from AOTG Cloud Server is required to gain access to AOTG API.
 
Obtain '''AccessToken''' from AOTG Cloud Server is required to gain access to AOTG API.
   
Line 7: Line 8:
 
Which means programmer only need to authenticate with AOTG Cloud Server once, and make subsequent request until it is expired.
 
Which means programmer only need to authenticate with AOTG Cloud Server once, and make subsequent request until it is expired.
   
  +
{|class="wikitable"
  +
|-
  +
|'''Username and password'''
  +
|Authentication is required to identify the requester. Username and password can be obtained after registration.<br/>To register see [[Begin AutoCount Accounting Integration via AOTG API]].
  +
|-
  +
|'''API Key'''
  +
|It is essential to identify the account book that has been registered with AOTG Server.<br/>See [[Begin AutoCount Accounting Integration via AOTG API]] on activate Account Book.
  +
|}
  +
  +
==Code Snippets==
  +
{{AOTGApiCodeSnippetTab
  +
|RestSharp=
  +
<syntaxhighlight lang="C#">
  +
var client = new RestClient("http://aotg.cloud:8080/api/public/v1/TokenAuth/Authenticate");
  +
var request = new RestRequest(Method.POST);
  +
request.AddHeader("cache-control", "no-cache");
  +
request.AddHeader("Content-Type", "application/json");
  +
request.AddParameter("undefined", "{\n \"UserName\": \"tester@autocountsoft.com\",\n \"Password\": \"Test123Password\",\n \"ApiKey\": \"3DT88-3BF2-4D08-BA6C-E8E8E\"\n}\n", ParameterType.RequestBody);
  +
IRestResponse response = client.Execute(request);
  +
</syntaxhighlight>
  +
|PHPcURL=
  +
<syntaxhighlight lang="PHP">
  +
<?php
  +
  +
$curl = curl_init();
  +
  +
curl_setopt_array($curl, array(
  +
CURLOPT_PORT => "8080",
  +
CURLOPT_URL => "http://aotg.cloud:8080/api/public/v1/TokenAuth/Authenticate",
  +
CURLOPT_RETURNTRANSFER => true,
  +
CURLOPT_ENCODING => "",
  +
CURLOPT_MAXREDIRS => 10,
  +
CURLOPT_TIMEOUT => 30,
  +
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  +
CURLOPT_CUSTOMREQUEST => "POST",
  +
CURLOPT_POSTFIELDS => "{\n \"UserName\": \"tester@autocountsoft.com\",\n \"Password\": \"Test123Password\",\n \"ApiKey\": \"3DT88-3BF2-4D08-BA6C-E8E8E\"\n}\n",
  +
CURLOPT_HTTPHEADER => array(
  +
"Content-Type: application/json",
  +
"cache-control: no-cache"
  +
),
  +
));
  +
  +
$response = curl_exec($curl);
  +
$err = curl_error($curl);
  +
  +
curl_close($curl);
  +
  +
if ($err) {
  +
echo "cURL Error #:" . $err;
  +
} else {
  +
echo $response;
  +
}
  +
</syntaxhighlight>
  +
|PHPHttp=
  +
<syntaxhighlight lang="PHP">
  +
<?php
  +
  +
$request = new HttpRequest();
  +
$request->setUrl('http://aotg.cloud:8080/api/public/v1/TokenAuth/Authenticate');
  +
$request->setMethod(HTTP_METH_POST);
  +
  +
$request->setHeaders(array(
  +
'cache-control' => 'no-cache',
  +
'Content-Type' => 'application/json'
  +
));
  +
  +
$request->setBody('{
  +
"UserName": "tester@autocountsoft.com",
  +
"Password": "Test123Password",
  +
"ApiKey": "3DT88-3BF2-4D08-BA6C-E8E8E"
  +
}
  +
');
   
  +
try {
  +
$response = $request->send();
   
  +
echo $response->getBody();
  +
} catch (HttpException $ex) {
  +
echo $ex;
  +
}
  +
</syntaxhighlight>
  +
}}
   
  +
==Response==
  +
<syntaxhighlight lang="json-object" highlight="4">
  +
{
  +
"Id": "dddd32d-d99d-261f-dd90-8dcdd1de7d29",
  +
"Name": "ApiAuthenticate",
  +
"AccessToken": "SAMc13a36d2-a139-e911-b8b3-000d3aa04f3d",
  +
"ExpireTimestamp": 636874006917389182
  +
}
  +
</syntaxhighlight>
  +
Access Token is returned after successful authentication.
   
 
<br/>
 
<br/>

Latest revision as of 04:19, 28 February 2019

API Method

Http Method: POST
Method: /api/public/v1/TokenAuth/Authenticate
Content-Type: application/json
Parameters: 


Description

Obtain AccessToken from AOTG Cloud Server is required to gain access to AOTG API.

The AccessToken has an expiry date and time.
Which means programmer only need to authenticate with AOTG Cloud Server once, and make subsequent request until it is expired.

Username and password Authentication is required to identify the requester. Username and password can be obtained after registration.
To register see Begin AutoCount Accounting Integration via AOTG API.
API Key It is essential to identify the account book that has been registered with AOTG Server.
See Begin AutoCount Accounting Integration via AOTG API on activate Account Book.

Code Snippets

<?php

$request = new HttpRequest();
$request->setUrl('http://aotg.cloud:8080/api/public/v1/TokenAuth/Authenticate');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'cache-control' => 'no-cache',
  'Content-Type' => 'application/json'
));

$request->setBody('{
  "UserName": "tester@autocountsoft.com",
  "Password": "Test123Password",
  "ApiKey": "3DT88-3BF2-4D08-BA6C-E8E8E"
}
');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}

var client = new RestClient("http://aotg.cloud:8080/api/public/v1/TokenAuth/Authenticate");
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("undefined", "{\n  \"UserName\": \"tester@autocountsoft.com\",\n  \"Password\": \"Test123Password\",\n  \"ApiKey\": \"3DT88-3BF2-4D08-BA6C-E8E8E\"\n}\n", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_PORT => "8080",
  CURLOPT_URL => "http://aotg.cloud:8080/api/public/v1/TokenAuth/Authenticate",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "{\n  \"UserName\": \"tester@autocountsoft.com\",\n  \"Password\": \"Test123Password\",\n  \"ApiKey\": \"3DT88-3BF2-4D08-BA6C-E8E8E\"\n}\n",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "cache-control: no-cache"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

Code is not available


Response

{
    "Id": "dddd32d-d99d-261f-dd90-8dcdd1de7d29",
    "Name": "ApiAuthenticate",
    "AccessToken": "SAMc13a36d2-a139-e911-b8b3-000d3aa04f3d",
    "ExpireTimestamp": 636874006917389182
}

Access Token is returned after successful authentication.


See Also AOTG API


Go to menu

IconAC81.png Go to top
ProgrammerGo.jpg Resources For AutoCount Software Developers