Auth Provider
Install Dependency
Package: @affinidi-tdk/auth-provider
npm install @affinidi-tdk/auth-provider --saveCheck the latest version on the npm registry 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
Generates the Project Scoped Token required for calling Affinidi services.
When instantiating the AuthProvider class, provide the Personal Access Token (PAT) information including the private key to generate the authorisation token.
Constructor parameters
tokenId
string
RequiredprivateKey
string
Requiredpassphrase
string
OptionalprojectId
string
RequiredExample
import { AuthProvider } from '@affinidi-tdk/auth-provider'
const authProvider = new AuthProvider({
privateKey: '<PAT_PRIVATE_KEY_STRING>',
passphrase: '<PAT_KEY_PAIR_PASSPHRASE>',
tokenId: '<PAT_ID>',
projectId: '<PROJECT_ID>',
})fetchProjectScopedToken
Returns the Project Scoped Token used to call Affinidi Services.
No parameters required.
Example
import { AuthProvider } from '@affinidi-tdk/auth-provider'
const authProvider = new AuthProvider({
privateKey: '<PAT_PRIVATE_KEY_STRING>',
passphrase: '<PAT_KEY_PAIR_PASSPHRASE>',
tokenId: '<PAT_ID>',
projectId: '<PROJECT_ID>',
})
const projectScopedToken = await authProvider.fetchProjectScopedToken()createIotaToken
Creates an Affinidi Iota Framework token to generate the Iota Credentials used to sign the request token.
Parameters
iotaConfigId
string
Requireddid
string
RequirediotaSessionId
string
OptionalExample
import { AuthProvider } from '@affinidi-tdk/auth-provider'
const authProvider = new AuthProvider({
privateKey: '<PAT_PRIVATE_KEY_STRING>',
passphrase: '<PAT_KEY_PAIR_PASSPHRASE>',
tokenId: '<PAT_ID>',
projectId: '<PROJECT_ID>',
})
const iotaToken = await 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.