Request a Verifiable Credential (VC) for a Driver's License
Request a verifiable credential for a Driver's License using the BlockID SDK. Following the W3C Verifiable Credentials Data Model, developers can request credentials from BlockID with 1Kosmos as the Issuer and the Driver's License data as the Identifier and Credential Subject.
1Kosmos provides the Driver's License data as a digital credential and cryptographically signs it with its private key.
Prerequisites
To obtain the Driver's License document object, users must first complete a Driver's License Verification and copy the dl_object
from the polling function SUCCESS response.
Example SUCCESS response, with the dl_object
object that needs to be copied highlighted:

Request a Verifiable Credential (VC) for a Driver's License
Parameters
dns
: tenant domain as shown in the dashboardcommunityName
: tenant community as shown in the dashboardlicenseKey
: tenant license key as shown in the dashboardtype
: set asdl
document
: response from Driver's License Verification polling session response, underdl_object
userDid
: user DIDuserPublickey
: User Public keyuserUrn
: user URN
The code includes a function to generate new userDid
, userPublickey
and userUrn
parameters - developers can set these parameters to their own userDid
, userPublickey
and userUrn
values if desired.
Request Format
All requests are plug-and-play, not copy-paste. Please ensure that you are replacing the parameters in the request format below with the actual values
Please use the following format outlined below to request a Verifiable Credential for your Driver's License:
- NodeJS
- Java
- PHP
- Add dependencies and set tenant info
const BIDTenant = require("blockid-nodejs-helpers/BIDTenant.js");
const BIDVerifiableCredential = require("blockid-nodejs-helpers/BIDVerifiableCredential.js");
const { v4: uuidv4 } = require("uuid");
const tenantInfo = {
dns: "<tenant dns>",
communityName: "<community name>",
licenseKey: "<user license key>",
};
- Add the driver's license document
let document = {
<"dl_object JSON from polling response">
}
- Request VC for driver's license
async function requestVCForID(type, document) {
// Fetch user public key and private key
const keySet = BIDTenant.getKeySet();
let type = "dl";
let userDid = uuidv4();
let userPublickey = keySet.pKey;
let userUrn = `urn:${uuidv4()}`;
let issuedVerifiableCredential = await BIDVerifiableCredential.requestVCForID(
tenantInfo,
type,
document,
userDid,
userPublickey,
userUrn
);
console.log("issuedVerifiableCredentials::::::", issuedVerifiableCredential);
return issuedVerifiableCredential;
}
- Set tenant info
BIDTenantInfo tenantInfo = new BIDTenantInfo("<tenant dns>", "<communityName>", "<licenseKey>");
- Define VC parameters
String type = "dl";
String userPublickey = "<user public key>";
String userDid = UUID.randomUUID().toString();
String userUrn = "urn:" + UUID.randomUUID().toString();
- Add the driver's license document
BIDDLObjectData document = <"dl_object JSON from polling response">
- Request VC for driver's license
BIDDocumentVCResponse issuedVerifiableCredential = BIDVerifiableCredential.requestVCForID(tenantInfo, type, document, userDid, userPublickey, userUrn);
- Add dependencies and set tenant info
<?php
require_once("./BIDTenant.php");
require_once("./BIDVerifiableCredential.php");
$bidTenant = BIDTenant::getInstance();
$tenantInfo = array("dns" => "<tenant dns>", "communityName" => "<community>", "licenseKey" => "<license key>");
$keys = $bidTenant->getKeySet();
- Define VC parameters
$type = "dl";
$userDid = uniqid();
$userPublickey = $keys["publicKey"];
$userUrn = "urn:" . uniqid();
$issuer = array(
"id" => "did:" . uniqid()
);
- Add the driver's license document
$document = array("<dl_object JSON from polling response>");
- Request VC for driver's license
$issuedVerifiableCredential = BIDVerifiableCredential::requestVCForID($tenantInfo, $type, $document, $userDid, $userPublickey, $userUrn);
?>
Example Request
We've provided a complete example request below for reference:
Dummy information is provided in this example
- NodeJS
- Java
- PHP
const BIDVerifiableCredential = require("blockid-nodejs-helpers/BIDVerifiableCredential.js");
const BIDTenant = require("blockid-nodejs-helpers/BIDTenant.js");
const { v4: uuidv4 } = require("uuid");
let tenantInfo = {
dns: "blockid-trial.1kosmos.net",
communityName: "devx",
licenseKey: "9b074532-845b-4c75-ba3e-2b8950000000",
};
let document = {
type: "dl",
documentType: "DL",
category: "identity_document",
documentId: "W599Z0673B",
id: "W599Z0673B",
firstName: "CAMEMON",
lastName: "ABBA",
familyName: "ABBA",
middleName: "HASSAN",
givenName: "CAMEMON HASSAN",
fullName: "CAMEMON HASSAN ABBA",
dob: "19630620",
doe: "20270620",
doi: "20210605",
gender: "1",
height: "5'9",
eyeColor: "Brown",
street: "19821 NE 185TH ST",
city: "WOODINVILLE",
state: "WA",
country: "USA",
zipCode: "980779426",
};
async function requestVCForID(type, document) {
// Fetch user public key and private key
const keySet = BIDTenant.getKeySet();
let type = "dl";
let userDid = uuidv4();
let userPublickey = keys.pKey;
let userUrn = `urn:${uuidv4()}`;
let issuedVerifiableCredential = await BIDVerifiableCredential.requestVCForID(
tenantInfo,
type,
document,
userDid,
userPublickey,
userUrn
);
console.log("issuedVerifiableCredentials::::::", issuedVerifiableCredential);
return issuedVerifiableCredential;
}
BIDTenantInfo tenantInfo = new BIDTenantInfo("blockid-trial.1kosmos.net", "devx", "9b074532-845b-4c75-ba3e-2b8959800000");
String type = "dl";
String userPublickey = "zGNlDjMb6XV7xLRZR6XF2XRdUd8eUN3ggn21ejyP5qbn6/q3LnXTBQZA2/4Y63y9/JbSGEsMVkyVH2/hW4YAVQ==";
String userDid = UUID.randomUUID().toString();
String userUrn = "urn:" + UUID.randomUUID().toString();
// Define DL document
BIDDLObjectData document = new BIDDLObjectData();
document.type = "dl";
document.documentType = "DL";
document.category = "identity_document";
document.documentId = "W599Z0673B";
document.id = "W599Z0673B";
document.firstName = "CAMEMON";
document.lastName = "ABBA";
document.familyName = "ABBA";
document.middleName = "HASSAN";
document.givenName = "CAMEMON HASSAN";
document.fullName = "CAMEMON HASSAN ABBA";
document.dob = "19630620";
document.doe = "20270620";
document.doi = "20210605";
document.gender = "1";
document.height = "5'9";
document.eyeColor = "Brown";
document.street = "19821 NE 185TH ST";
document.city = "WOODINVILLE";
document.state = "WA";
document.country = "USA";
document.zipCode = "980779426";
// Fetch VC for DL
BIDDocumentVCResponse issuedVerifiableCredential = BIDVerifiableCredential.requestVCForID(tenantInfo, type, document, userDid, userPublickey, userUrn);
<?php
require_once("./BIDTenant.php");
require_once("./BIDVerifiableCredential.php");
$bidTenant = BIDTenant::getInstance();
$tenantInfo = array("dns" => "blockid-trial.1kosmos.net", "communityName" => "devx", "licenseKey" => "9b074532-845b-4c75-ba3e-2b8950000000");
$document = array(
"type" => "dl",
"documentType" => "DL",
"category" => "identity_document",
"documentId" => "W599Z0673B",
"id" => "W599Z0673B",
"firstName" => "CAMEMON",
"lastName" => "ABBA",
"familyName" => "ABBA",
"middleName" => "HASSAN",
"givenName" => "CAMEMON HASSAN",
"fullName" => "CAMEMON HASSAN ABBA",
"dob" => "19630620",
"doe" => "20270620",
"doi" => "20210605",
"gender" => "1",
"height" => "5'9",
"eyeColor" => "Brown",
"street" => "19821 NE 185TH ST",
"city" => "WOODINVILLE",
"state" => "WA",
"country" => "USA",
"zipCode" => "980779426"
);
/* Request VC for driver's license */
$issuedVerifiableCredential = BIDVerifiableCredential::requestVCForID($tenantInfo, $type, $document, $userDid, $userPublickey, $userUrn);
?>
Server Responses
Please review the responses below for expected output after requesting a VC verification. A successful request will include a crytographically signed credential.
Responses include dummy data as an example of a typical response
- 200
- 400
- 401
{
"vc":{
"@context":[
"https://www.w3.org/2018/credentials/v1",
{
"DriversLicenseCredential":"https://schema.org#DriversLicenseCredential",
"documentId":"https://schema.org#documentId",
"documentType":"https://schema.org#documentType",
"firstName":"https://schema.org#firstName",
"lastName":"https://schema.org#lastName",
"dob":"https://schema.org#dob",
"doe":"https://schema.org#doe",
"doi":"https://schema.org#doi",
"gender":"https://schema.org#gender",
"street":"https://schema.org#street",
"city":"https://schema.org#city",
"state":"https://schema.org#state",
"country":"https://schema.org#country",
"zipCode":"https://schema.org#zipCode",
"publicKey":"https://schema.org#publicKey"
},
"https://w3id.org/security/suites/ed25519-2020/v1"
],
"id":"did:blockid:442ac157-4fb2-4dd3-99b3-ee4306deb5d1",
"type":[
"VerifiableCredential",
"DriversLicenseCredential"
],
"issuer":{
"id":"did:blockid:dmv:USA:WA"
},
"issuanceDate":"2022-12-12T05:17:50.149Z",
"expirationDate":"2027-06-20T00:00:00.000Z",
"credentialSubject":{
"documentId":"W599Z0673B",
"documentType":"DL",
"firstName":"CAMEMON",
"lastName":"ABBA",
"dob":"1963-06-20",
"doe":"2027-06-20",
"doi":"2021-06-05",
"gender":"1",
"street":"19821 NE 185TH ST",
"city":"WOODINVILLE",
"state":"WA",
"country":"USA",
"zipCode":"980779426",
"id":"did:2a651b36-c582-46cb-995c-f60380104c70",
"publicKey":"aRnlolY2VlKAgOsdB2zmry0YzfiXYDt5GrCYyZIX4ITkNpMMuoTR/rKHuzDr7hKBhwBnAm+6LGnyuPSY/WK9XQ=="
},
"proof":{
"type":"Ed25519Signature2020",
"created":"2022-12-12T05:17:50Z",
"verificationMethod":"did:key:blockid:z6MkvFNv22WzDetLgdzYidCFQJosD5Z9pDr9cmX7RtREuoji",
"proofPurpose":"assertionMethod",
"proofValue":"z3sMWYFHUZeo11jysZMX2f2dVpubJ47Li6uJHYBUYCWR8UjCp3wszbfy6ZBmy9YBj4HAw2kF6zDyagqsUh43zZrRh"
},
"statusUrl":"https://blockid-trial.1kosmos.net/vcs/tenant/63627082d0b7e36525e281aa/community/63627302d0b7e36525e2828d/vc/did:blockid:442ac157-4fb2-4dd3-99b3-ee4306deb5d1/status"
}
}
{
"error_code": 400,
"message":"Invalid Request"
}
{
"error_code": 401,
"message":"Unauthorized"
}