Auth Provider
Install Dependency
Package: affinidi-tdk/affinidi-tdk-php
composer require affinidi-tdk/affinidi-tdk-phpCheck the latest version on the Packagist repository or view the source on GitHub.
API Endpoints
URLs required to initiate integration with Affinidi TDK.
Token Endpoint
Endpoint to generate access token to call Affinidi Services with TDK.
https://apse1.auth.developer.affinidi.io/auth/oauth2/tokenAPI Gateway URL
Base API URL of Affinidi Services.
https://apse1.api.affinidi.ioClasses and Methods
AuthProvider API
Used to generate Project Scoped Token required for calling Affinidi services (Clients).
When initiating the AuthProvider class, provide the Token information including the public/private key information to generate the Authorisation Token required.
AuthProvider (constructor)
Initialises AuthProvider with the Personal Access Token credentials required to generate authorisation tokens.
Parameters
projectId
string
RequiredprivateKey
string
Requiredpassphrase
string
OptionaltokenId
string
RequiredExample
require_once 'vendor/autoload.php';
use AffinidiTdk\AuthProvider\AuthProvider;
$params = [
'privateKey' => '<PAT_PRIVATE_KEY_STRING>',
'passphrase' => '<PAT_KEY_PAIR_PASSPHRASE>',
'tokenId' => '<PAT_ID>',
'projectId' => '<PROJECT_ID>',
];
$authProvider = new AuthProvider($params);
// Fetch token directly
$projectScopedToken = $authProvider->fetchProjectScopedToken();
// Or use as a callback
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];fetchProjectScopedToken
Returns the generated project-scoped token for calling Affinidi services.
No parameters required.
Example
require_once 'vendor/autoload.php';
use AffinidiTdk\AuthProvider\AuthProvider;
$authProvider = new AuthProvider([
'privateKey' => '<PAT_PRIVATE_KEY_STRING>',
'passphrase' => '<PAT_KEY_PAIR_PASSPHRASE>',
'tokenId' => '<PAT_ID>',
'projectId' => '<PROJECT_ID>',
]);
$projectScopedToken = $authProvider->fetchProjectScopedToken();createIotaToken
Creates an Affinidi Iota Framework token to generate Iota Credentials for signing the request token.
Parameters
iotaConfigId
string
Requireddid
string
RequirediotaSessionId
string
OptionalExample
require_once 'vendor/autoload.php';
use AffinidiTdk\AuthProvider\AuthProvider;
$authProvider = new AuthProvider([
'privateKey' => '<PAT_PRIVATE_KEY_STRING>',
'passphrase' => '<PAT_KEY_PAIR_PASSPHRASE>',
'tokenId' => '<PAT_ID>',
'projectId' => '<PROJECT_ID>',
]);
$iotaToken = $authProvider->createIotaToken('<IOTA_CONFIGURATION_ID>', '<LOGGED_IN_USER_DID>');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.