Credential Issuance
Install Dependency
Package: affinidi-tdk/affinidi-tdk-php
composer require affinidi-tdk/affinidi-tdk-php
You can check the latest version of this module on the Packagist repository or view the source code at the GitHub repository.
Classes and Methods
Configuration API
Manage the issuance configuration for the project. Project only one issuance configuration.
createIssuanceConfig
Create an issuance configuration for the project.
Parameters
CreateIssuanceConfigInput [Object]
JSON object to provide the details of the configuration. See more here.
Example
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\CredentialIssuanceClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
// Configure API key authorization: ProjectTokenAuth
$config = CredentialIssuanceClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new CredentialIssuanceClient\Api\ConfigurationApi(
new GuzzleHttp\Client(),
$config
);
try {
$request = array(
'credentialSupported' => array(
array(
"credentialTypeId" => "SchemaOne",
"jsonSchemaUrl" => "https://schema.affinidi.io/SchemaOneV1R1.json",
"jsonLdContextUrl" => "https://schema.affinidi.io/SchemaOneV1R1.jsonld"
)
),
"issuerWalletId" => "<Wallet_ID>",
"credentialOfferDuration" => 3600,
"format" => "ldp_vc",
);
$result = $apiInstance->createIssuanceConfigRequest($request);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}
deleteIssuanceConfigById
Delete the issuance configuration by ID.
Parameters
configurationId [String]
ID of the issuance configuration to delete.
Example
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\CredentialIssuanceClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
// Configure API key authorization: ProjectTokenAuth
$config = CredentialIssuanceClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new CredentialIssuanceClient\Api\ConfigurationApi(
new GuzzleHttp\Client(),
$config
);
try {
$configurationId = "<Config_ID>";
$apiInstance->deleteIssuanceConfigById($configurationId);
} catch (Exception $e) {
echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}
getIssuanceConfigById
Retrieves the Issuance Configuration details by ID.
Parameters
configurationId [String]
ID of the issuance configuration to retrieve.
Example
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\CredentialIssuanceClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
// Configure API key authorization: ProjectTokenAuth
$config = CredentialIssuanceClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new CredentialIssuanceClient\Api\ConfigurationApi(
new GuzzleHttp\Client(),
$config
);
try {
$configurationId = "<Config_ID>";
$result = $apiInstance->getIssuanceConfigById($configurationId);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}
getIssuanceConfigList
Get the list of issuance configuration for the current project.
Parameters
No Parameters Required
Example
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\CredentialIssuanceClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
// Configure API key authorization: ProjectTokenAuth
$config = CredentialIssuanceClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new CredentialIssuanceClient\Api\ConfigurationApi(
new GuzzleHttp\Client(),
$config
);
try {
$result = $apiInstance->getIssuanceConfigList();
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}
updateIssuanceConfigById
Update the existing Issuance Configuration by ID.
Parameters
configurationId [String]
ID of the issuance configuration to retrieve.
UpdateIssuanceConfigInput [Object]
JSON object to provide the details to update the issuance configuration. See more here.
Example
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\CredentialIssuanceClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
// Configure API key authorization: ProjectTokenAuth
$config = CredentialIssuanceClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new CredentialIssuanceClient\Api\ConfigurationApi(
new GuzzleHttp\Client(),
$config
);
try {
$configurationId = "3dfe29b0-941a-4237-8587-c2bd895cb90a";
$request = array(
'credentialSupported' => array(
array(
"credentialTypeId" => "SchemaOne",
"jsonSchemaUrl" => "https://schema.affinidi.io/SchemaOneV1R1.json",
"jsonLdContextUrl" => "https://schema.affinidi.io/SchemaOneV1R1.jsonld"
)
),
"issuerWalletId" => "86d87d4cfba78133864749518ceaec4a",
"credentialOfferDuration" => 4600,
"format" => "ldp_vc",
);
$result = $apiInstance->updateIssuanceConfigById($configurationId, $request);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}
Issuance API
Use to initiate issuance of the credential and check the status.
issuanceState
Retrieve the status of issuance.
Parameters
issuanceId [String]
ID of the initiated issuance.
projectId [String]
Project ID from where the issuance was initiated.
Example
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\CredentialIssuanceClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
// Configure API key authorization: ProjectTokenAuth
$config = CredentialIssuanceClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new CredentialIssuanceClient\Api\IssuanceApi(
new GuzzleHttp\Client(),
$config
);
try {
$issuanceId = "<Issuance_ID>"
$projectId = "<Project_ID>";
$result = $apiInstance->issuanceState($issuanceId, $projectId);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}
listIssuance
Get the list of issuance initiated in the Project.
Parameters
projectId [String]
Project ID from where to list the issuance.
Example
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\CredentialIssuanceClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
// Configure API key authorization: ProjectTokenAuth
$config = CredentialIssuanceClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new CredentialIssuanceClient\Api\IssuanceApi(
new GuzzleHttp\Client(),
$config
);
try {
$projectId = "<Project_ID>";
$result = $apiInstance->listIssuance($projectId);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}
startIssuance
Used to initiate the issuance of the credential.
Parameters
projectId [String]
Project ID from where to initiate the issuance.
StartIssuanceInput [Object]
JSON object to provide the details of the credentials to issue. See more here.
Example
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\CredentialIssuanceClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
// Configure API key authorization: ProjectTokenAuth
$config = CredentialIssuanceClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new CredentialIssuanceClient\Api\IssuanceApi(
new GuzzleHttp\Client(),
$config
);
try {
$projectId = "<Project_ID>";
$request = array(
"data" => array(
array(
"credentialTypeId" => "SchemaOne",
"credentialData" => array(
"Firstname" => "FirstName",
"Lastname" => "LastName",
"dob" => "1970-01-01"
)
)
),
"holderDid" => "did:key:holder-did-value",
"claimMode" => "FIXED_HOLDER"
);
$result = $apiInstance->startIssuance($projectId, $request);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}
Credentials API
Issue a Verifiable Credentials to the users.
generateCredentials
Generate and issue a credentil offer to the user.
Parameters
projectId [String]
Project ID from where you want to issue the credential.
CreateCredentialInput [Object]
JSON object to provide the details of the credential to generate. See more here.
Example
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\CredentialIssuanceClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
// Configure API key authorization: ProjectTokenAuth
$config = CredentialIssuanceClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new CredentialIssuanceClient\Api\CredentialsApi(
new GuzzleHttp\Client(),
$config
);
try {
$projectId = "<Project_ID>"
$request = array(
"credential_identifier" => "SchemaOne",
"proof" => array(
"proof_type" => "jwt",
"jwt" =>
"eyJ0eXAiOiJvcGVuaWQ0dmNpLXByb29mK2p3dCIsImFsZyI6IkVTMjU2IiwiandrI
jp7Imt0eSI6IkVDIiwiY3J2IjoiUC0yNTYiLCJ4IjoiblVXQW9BdjNYWml0aDhFN2k
xOU9kYXhPTFlGT3dNLVoyRXVNMDJUaXJUNCIsInkiOiJIc2tIVThCalVpMVU5WHFpN
1N3bWo4Z3dBS18weGtjRGpFV183MVNvc0VZIn19.eyJhdWQiOiJodHRwczovL2NyZW
RlbnRpYWwtaXNzdWVyLmV4YW1wbGUuY29tIiwiaWF0IjoxNzAxOTYwNDQ0LCJub25j
ZSI6IkxhclJHU2JtVVBZdFJZTzZCUTR5bjgifQ.-a3EDsxClUB4O3LeDD5DVGEnNMT
01FCQW4P6-2-BNBqc_Zxf0Qw4CWayLEpqkAomlkLb9zioZoipdP-jvh1WlA"
)
);
$result = $apiInstance->generateCredentials($projectId, $request);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}
Default API
Revoke a revocable Verifiable Credentials issued to the users.
changeCredentialStatus
Updates the status of the credential (e.g., REVOKED).
Parameters
projectId [String]
Project ID from where the credential is issued.
configurationId [String]
Configuration ID from where the credential is issued.
ChangeCredentialStatusInput [Object]
JSON object with details of the credential to revoke. See more here.
Example
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\CredentialIssuanceClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
// Configure API key authorization: ProjectTokenAuth
$config = CredentialIssuanceClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new CredentialIssuanceClient\Api\DefaultApi(
new GuzzleHttp\Client(),
$config
);
try {
$projectId = "<Project_ID>";
$configId = "<Config_ID>";
$request = array(
"changeReason" => "INVALID_CREDENTIAL",
"issuanceRecordId" => "<Record_ID>"
);
$result = $apiInstance->changeCredentialStatus($projectId, $configId, $request);
return $result;
} catch (Exception $e) {
echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}
listIssuanceDataRecords
Retrieves the list of records of revocable credentials. The list contains information about the issued credential, such as status, including the record ID, which you can use to revoke a particular credential.
Parameters
projectId [String]
Project ID from where the credential is issued.
configurationId [String]
Configuration ID from where the credential is issued.
limit [Integer]
Maximum number of records to fetch in a list.
exclusiveStartKey [String]
The base64url encoded key of the first item that this operation will evaluate (it is not returned). Use the value that was returned in the previous operation.
Example
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\CredentialIssuanceClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
// Configure API key authorization: ProjectTokenAuth
$config = CredentialIssuanceClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new CredentialIssuanceClient\Api\DefaultApi(
new GuzzleHttp\Client(),
$config
);
try {
$projectId = "<Project_ID>";
$configId = "<Config_ID>";
$result = $apiInstance->listIssuanceDataRecords($projectId, $configId);
return $result;
} catch (Exception $e) {
echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}
Offer API
Used to get the credential offer initiated by the Issuance API.
getCredentialOffer
Retrieves the credential offer details.
Parameters
issuanceId [String]
ID of the issuance initiated.
Example
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\CredentialIssuanceClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
// Configure API key authorization: ProjectTokenAuth
$config = CredentialIssuanceClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new CredentialIssuanceClient\Api\OfferApi(
new GuzzleHttp\Client(),
$config
);
try {
$projectId = "<Project_ID>";
$issuanceId = "<Issuance_ID>";
$result = $apiInstance->getCredentialOffer($projectId, $issuanceId);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}
WellKnown API
Used to get the WellKnown OpenID Credential Issuer information.
getWellKnownOpenIdCredentialIssuer
Retrieves the credential issuer well-known configurations.
Parameters
No Parameters Required
Example
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\CredentialIssuanceClient;
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
// Configure API key authorization: ProjectTokenAuth
$config = CredentialIssuanceClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new CredentialIssuanceClient\Api\WellKnownApi(
new GuzzleHttp\Client(),
$config
);
try {
$projectId = "<Project_ID>";
$result = $apiInstance->getWellKnownOpenIdCredentialIssuer($projectId);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}
Glad to hear it! Please tell us how we can improve more.
Sorry to hear that. Please tell us how we can improve.
Thank you for sharing your feedback so we can improve your experience.