Knowledgebase
Authentication
IA ViS requires the calling application to supply authentication credentials as ‘AUTHORIZATION’ HTTP header to generate a token. If authentication is successful, the link returns a JSON string that contains a dynamically generated "token". The "token" is then used with the functions scan_image_data or scan_image_url.
URLhttps://iavis.image-analyzer.com/token
JSON Payload
No payload required.
JSON Response
{
"token": "Unique token id returned after successful authentication.",
"remaining_scan_count": "Count of remaining scan tokens",
"category_list":
[
{
"id": "Id for the category",
"name": "Name of the Category",
"description": "Short description about the category."
}
],
"error_code": "Error code in case the result is false",
"result": "true or falsei.e. success or failure of authentication."
}
JSON Response Example
{
"token": "6d4b6a83-debd-43dc-8c21-0e2fcea2a812",
"remaining_scan_count": 2785,
"category_list":
[
{
"description": "Detects images containing terrorist militants, beheadings, executions, propaganda, acts of terrorism, flags and insignia.",
"id": 5580,
"name": "Terrorism Category"
},
{
"description": "Detects images containing handheld weapons such as rifles, machine guns, hand guns, knives, swords, grenade launchers and people holding firearms.",
"id": 6377,
"name": "Weapons Category"
},
{
"description": "Detects images that contain commercial pornography, amateur pornography, sexting selfies, nudity, sex acts, greyscale pornographic images, sexually explicit cartoons and manga.",
"id": 7174,
"name": "Pornography Category"
},
{
"description": "Detects images containing graphic violence, bloody wounds, accident victims, beatings, mutilation, decapitation and other images that contain blood and guts",
"id": 7971,
"name": "Gore Category"
},
{
"description": "Detects images containing illegal drugs, drug use, drug paraphernalia, plants and symbols relating to drugs.",
"id": 8768,
"name": "Drugs Category"
}
],
"error_code": "",
"result": "True"
}
Sample Code
Below is the sample code that can be used for authentication
PHP:
<?php
$strUname = "<username>";
$strPassword = "<password>";
$strAccessToken = base64_encode($strUname.":".$strPassword);
$ch = curl_init("https://iavis.image-analyzer.com/token");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: json/auth', 'Authorization:'.$strAccessToken));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
var_dump($response);
?>
PERL:
use strict;
use MIME::Base64;
use REST::Client;
my $strUname = "<username>";
my $strPassword = "<password>";
my $client = REST::Client->new();
$client->setHost("https://iavis.image-analyzer.com");
$client->addHeader("Authorization", "Basic " .
encode_base64("$strUname:$strPassword", ""));
my $response = $client->POST("/token");
print $client->responseContent(), "\n";
PYTHON:
import requests
import json
strUname = "<username>"
strPassword = "<password>"
client_auth = requests.auth.HTTPBasicAuth(strUname, strPassword)
response = requests.post("https://iavis.image-analyzer.com/token", auth=client_auth)
token_json = response.json()
print(json.dumps(token_json))
C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
namespace Sample_Token
{
class Program
{
static void Main(string[] args)
{
string strUserName = "<username>";
string strPassword = "<password>";
string strAuthorization = strUserName + ":" + strPassword;
byte[] toEncodeAuthorization = System.Text.ASCIIEncoding.ASCII.GetBytes(strAuthorization);
string strBase64Authorization = System.Convert.ToBase64String(toEncodeAuthorization);
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("https://iavis.image-analyzer.com/token");
req.Timeout = 100000000;
req.Method = "POST";
req.Headers.Add("Authorization", strBase64Authorization);
Stream dataStream = req.GetRequestStream();
WebResponse response = req.GetResponse();
dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string Result = reader.ReadToEnd();
reader.Close();
dataStream.Close();
response.Close();
if (string.Empty != Result)
{
Console.WriteLine(Result);
Console.ReadLine();
}
}
}
}