Auth Provider
Install Dependency
Package: affinidi_tdk_auth_provider
dart pub add affinidi_tdk_auth_providerCheck the latest version on pub.dev 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.
Required Parameters
- tokenId: ID of the Personal Access Token (PAT). Use
TOKEN_IDas the environment variable for Java. - passphrase: Passphrase of the Private key if configured. Use
PASSPHRASEas the environment variable for Java. - privateKey: Private key string to use to sign the token. Use
PRIVATE_KEYas the environment variable for Java. - projectId: Project ID to generate the Token. Use
PROJECT_IDas the environment variable for Java.
Example
import 'package:affinidi_tdk_auth_provider/affinidi_tdk_auth_provider.dart';
// NOTE: set your variables for PAT
final privateKey = '<PAT_PRIVATE_KEY_STRING>';
final passphrase = '<PAT_KEY_PAIR_PASSPHRASE>';
final tokenId = '<PAT_ID>';
final projectId = '<PROJECT_ID>';
final authProvider = AuthProvider(
privateKey: privateKey,
passphrase: passphrase,
tokenId: tokenId,
projectId: projectId,
);fetchProjectScopedToken
Return the generated Project Scoped Token to use for calling the Affinidi Services.
No parameters required.
Example
import 'package:affinidi_tdk_auth_provider/affinidi_tdk_auth_provider.dart';
final privateKey = '<PAT_PRIVATE_KEY_STRING>';
final passphrase = '<PAT_KEY_PAIR_PASSPHRASE>';
final tokenId = '<PAT_ID>';
final projectId = '<PROJECT_ID>';
final authProvider = AuthProvider(
privateKey: privateKey,
passphrase: passphrase,
tokenId: tokenId,
projectId: projectId,
);
final projectScopedToken = await provider.fetchProjectScopedToken();createIotaToken
Create an Affinidi Iota Framework token to generate the Iota Credentials to sign the request token.
Parameters
iotaConfigId
String
Requireddid
String
RequirediotaSessionId
String
OptionalExample
import 'package:affinidi_tdk_auth_provider/affinidi_tdk_auth_provider.dart';
final privateKey = '<PAT_PRIVATE_KEY_STRING>';
final passphrase = '<PAT_KEY_PAIR_PASSPHRASE>';
final tokenId = '<PAT_ID>';
final projectId = '<PROJECT_ID>';
final authProvider = AuthProvider(
privateKey: privateKey,
passphrase: passphrase,
tokenId: tokenId,
projectId: projectId,
);
final iotaToken = provider.createIotaToken(iotaConfigId: "<IOTA_CONFIGURATION_ID>", did: "<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.