GET /token?id={app-id}&bcid={BCID}
Requests a BWS
token to be used for authorization with most of the other BWS Web APIs. The issued token will be assigned
to the specified user and has a very short lifetime, i.e. it expires after about ten minutes as it is typically only used
for one biometric task like verification or enrollment (including retries).
This API call requires Basic Authentication, i.e. you have to provide an HTTP authorization header using the authorization method Basic and the base64 encoded string App-ID:App-Secret (therefore the transport is secured using TLS/SSL).
Required. The Biometric Class ID (BCID) of the person for whom the token shall be issued, i.e. the user that is going to perform a biometric task using this token.
livenessdetection
!
verify
. A string that specifies the task the issued token shall be used for:
Currently the tasks verify
(default), identify
, enroll
and livenessdetection
are defined.
Tokens created for the task verify are intended to be used together with the Verify Web API,
identify-tokens are used with the Identify Web API, enroll-tokens with the Enroll Web API
and livenessdetection-tokens with the LivenessDetection Web API. With all kind of tokens
access to the Upload Web API is allowed of course.
3
. An non-zero integer value up to 15 that specifies the maximum number of tries
an application or a user is allowed to perform with the issued token. The default is 3 attempts.
true
. A boolean parameter to switch off live data detection.
When set to true
(the default), liveness detection is required and the intended task shall fail,
as soon as it cannot undoubtedly determine that the given data is live data.
When set to false
, live data detection is not required (except for the livenessdetection task
that always performs a liveness detection of course).
Optional, defaults to false
. A boolean parameter only interpreted if liveness detection
is switched on: if set to true
, the challenge-response mechanism is activated, i.e.
additionally to the standard liveness detection the user has to respond according to the
challenges provided by the system.
3
. An integer value between 2 and 7 that specifies the number of
challenges that shall be embedded in the token in case that liveness detection with challenge
response is enabled.
false
. A boolean parameter used in conjunction with the verify task
that if set to true and the verification succeeded it allows to automatically enroll the
uploaded samples. This ensures, that the biometric template of the person is automatically
adapted and always assembled from current samples. When set to false
(the default), no
automatic enrollment will be performed.
Face,Periocular
. The traits that shall be used for the biometric operation.
The Token Web API returns a string containing the issued BWS token. The BWS uses a JSON Web Token (JWT) to represent the issued claims as a JSON object. The object is encoded as JSON Web Signature (JWS) which means that the claims are digitally signed (HMACed), base64url encoded and finally joined with a period.
{"typ":"JWT","alg":"HS256"}
const string APP_IDENTIFIER = "";
const string APP_SECRET = "";
const string ENDPOINT = "https://bws.bioid.com/extension/";
const string STORAGE = "";
const int PARTITION = 0;
const int CLASSID = 0;
static string bcid = STORAGE + "." + PARTITION + "." + CLASSID;
public enum TokenFor { verify, identify, enroll, livenessdetection }
private static async Task<string> TokenAsync(string bcid, TokenFor forTask = TokenFor.verify)
{
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic",
Convert.ToBase64String(Encoding.ASCII.GetBytes($"{APP_IDENTIFIER}:{APP_SECRET}")));
Console.Write("Get BWS token: ");
using (var response = await client.GetAsync(ENDPOINT + $"token?id={APP_IDENTIFIER}&bcid={bcid}&task={forTask}"))
{
if (response.StatusCode == HttpStatusCode.OK)
{
Console.WriteLine("succeeded");
return await response.Content.ReadAsStringAsync();
}
else
{
Console.WriteLine(response.StatusCode.ToString());
return "";
}
}
}
}
// using OkHttpClient from the OkHttp library
HttpUrl url = HttpUrl.parse("https://bws.bioid.com/extension/token").newBuilder()
.addQueryParameter("id", APP_IDENTIFIER)
.addQueryParameter("bcid", STORAGE + "." + PARTITION + "." + CLASS_ID)
.build();
Request request = new Request.Builder()
.url(url)
.addHeader("Authorization", Credentials.basic(APP_IDENTIFIER, APP_SECRET))
.build();
OkHttpClient client = new OkHttpClient();
Response response = client.newCall(request).execute();
String token = response.body().string();
if (response.code() == 200) {
System.out.println("token=" + token);
}
return token;