Auth Provider
Install Dependency
Package: pkg:maven/com.affinidi.tdk/auth.provider
<dependency>
<groupId>com.affinidi.tdk</groupId>
<artifactId>auth.provider</artifactId>
<version><version_number></version>
</dependency>Check the latest version on the Maven Central 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
import com.affinidi.tdk.authProvider.AuthProvider;
try {
// Pass values directly
AuthProvider authProvider = new AuthProvider.Configurations()
.projectId("<PROJECT_ID>")
.privateKey("<PAT_PRIVATE_KEY_STRING>")
.passphrase("<PAT_KEY_PAIR_PASSPHRASE>")
.tokenId("<PAT_ID>")
.build();
// Or read from environment variables
AuthProvider authProviderFromEnv = new AuthProvider.Configurations().buildWithEnv();
} catch (Exception e) {
e.printStackTrace();
}fetchProjectScopedToken
Returns the generated project-scoped token for calling Affinidi services.
No parameters required.
Example
import com.affinidi.tdk.authProvider.AuthProvider;
try {
AuthProvider authProvider = new AuthProvider.Configurations()
.projectId("<PROJECT_ID>")
.privateKey("<PAT_PRIVATE_KEY_STRING>")
.passphrase("<PAT_KEY_PAIR_PASSPHRASE>")
.tokenId("<PAT_ID>")
.build();
String projectToken = authProvider.fetchProjectScopedToken();
System.out.println(projectToken);
} catch (Exception e) {
e.printStackTrace();
}createIotaToken
Creates an Affinidi Iota Framework token to generate Iota Credentials for signing the request token.
Parameters
iotaConfigId
String
Requireddid
String
RequirediotaSessionId
String
OptionalExample
import com.affinidi.tdk.authProvider.AuthProvider;
import com.affinidi.tdk.authProvider.types.IotaJwtOutput;
try {
AuthProvider authProvider = new AuthProvider.Configurations()
.projectId("<PROJECT_ID>")
.privateKey("<PAT_PRIVATE_KEY_STRING>")
.passphrase("<PAT_KEY_PAIR_PASSPHRASE>")
.tokenId("<PAT_ID>")
.build();
IotaJwtOutput iotaToken = authProvider.signIotaJwt(
"<IOTA_CONFIGURATION_ID>",
"<LOGGED_IN_USER_DID>",
""
);
System.out.println(iotaToken.getIotaJwt());
} catch (Exception e) {
e.printStackTrace();
}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.