Get Access Token
The /get-access-token endpoint provides a JWT authentication token for authorization. To acquire a valid token, the user must make a request to the /get-access-token endpoint of AML Watcher using their email and password.
info
Each access token is valid for three hours (180 minutes)
After availing the token, the user needs to create or get API key using the access token.
Endpoint: https://api.amlwatcher.com/api/get-access-token
Method: POST
- HTTP
- Javascript
- PHP
- Python
- Ruby
- Java
- cURL
- C#
- Go
Sample Request
POST /api/get-access-token HTTP/1.1
Host: api.amlwatcher.com
Content-Type: application/json
Content-Length: 68
{
"email":"email",
"password":"password"
}
Sample Request
var myHeaders = new Headers();
myHeaders.append("Accept", "application/json");
var formdata = new FormData();
formdata.append("email", "[email protected]");
formdata.append("password", "user@123");
var requestOptions = {
method: "POST",
headers: myHeaders,
body: formdata,
redirect: "follow",
};
fetch("https://api.amlwatcher.com/api/get-access-token", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.log("error", error));
Sample Request
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.amlwatcher.com/api/get-access-token',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array('email' => '[email protected]','password' => 'user@123'),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Sample Request
import requests
import json
url = "https://api.amlwatcher.com/api/get-access-token"
payload = json.dumps({
'email': '[email protected]',
'password': 'user@123'
})
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
Sample Request
require "uri"
require "net/http"
url = URI("https://api.amlwatcher.com/api/get-access-token")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
form_data = [['email', '[email protected]'],['password', 'user@123']]
request.set_form form_data, 'multipart/form-data'
response = https.request(request)
puts response.read_body
Sample Request
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) {
try {
URL url = new URL("https://api.amlwatcher.com/api/get-access-token");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "application/json");
con.setDoOutput(true);
String jsonInputString = "{\n \"email\":\"[email protected]\",\n \"password\":\"user@123\"\n}";
try (OutputStream os = con.getOutputStream()) {
byte[] input = jsonInputString.getBytes("utf-8");
os.write(input, 0, input.length);
}
int code = con.getResponseCode();
System.out.println("Response Code: " + code);
if (code >= 200 && code < 300) {
try (BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream(), "utf-8"))) {
StringBuilder response = new StringBuilder();
String responseLine = null;
while ((responseLine = br.readLine()) != null) {
response.append(responseLine.trim());
}
System.out.println(response.toString());
}
} else {
System.err.println("Error: " + code + " - " + con.getResponseMessage());
try (BufferedReader br = new BufferedReader(new InputStreamReader(con.getErrorStream(), "utf-8"))) {
StringBuilder response = new StringBuilder();
String responseLine = null;
while ((responseLine = br.readLine()) != null) {
response.append(responseLine.trim());
}
System.err.println(response.toString());
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
Sample Request
curl --location --request POST 'https://api.amlwatcher.com/api/get-access-token'
--header "Content-type: application/json"
--data-raw '{"email":"[email protected]","password":"user@123"}'
Sample Request
using System;
using System.Threading.Tasks;
using RestSharp;
public class Program
{
public static async Task Main(string[] args)
{
var options = new RestClientOptions("https://api.amlwatcher.com")
{
Timeout = TimeSpan.FromSeconds(30)
};
var client = new RestClient(options);
var request = new RestRequest("/api/get-access-token", Method.Post);
// Assuming the API expects JSON payload
request.AddJsonBody(new { email = "[email protected]", password = "user@123" });
request.AddHeader("Content-Type", "application/json");
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
}
}
Sample Request
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
url := "https://api.amlwatcher.com/api/get-access-token"
method := "POST"
payload := map[string]string{
"email": "[email protected]",
"password": "user@123",
}
payloadBytes, err := json.Marshal(payload)
if err != nil {
fmt.Println(err)
return
}
client := &http.Client{}
req, err := http.NewRequest(method, url, bytes.NewBuffer(payloadBytes))
if err != nil {
fmt.Println(err)
return
}
req.Header.Set("Content-Type", "application/json")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
Request
Parameters | Required | Type | Description |
---|---|---|---|
Yes | String | Email of registered user. Example: [email protected] | |
password | Yes | String | Password assigned against registered email of user. Min: 8 characters Example: amlWatcher@!# |
Response
Parameters | Description |
---|---|
error | Whenever there is an error in your request, this param will have details of that error; otherwise it’ll remain empty. |
status | The status field is set to either “SUCCESS” or “FAIL”, indicating that the API request resulted in a successful or failure/error condition respectively. |
data | An array containing the actual response elements. |
Sample Response
{
"error": false,
"status": "SUCCESS",
"data": {
"access_token": "Random Access Token"
}
}