Auth Provider
Supported Languages
Package: @affinidi-tdk/auth-provider
npm install @affinidi-tdk/auth-provider --save
Package: affinidi_tdk_auth_provider
pip install affinidi_tdk_auth_provider
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/token
API Gateway URL
Base API URL of Affinidi Services.
https://apse1.api.affinidi.io
Classes 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 information:
- apiGatewayUrl: API Gateway URL of the Affinidi Services. Value is
https://apse1.api.affinidi.io
. - keyId: Key ID.
- tokenId: ID of the Personal Access Token (PAT).
- passphrase: Passphrase of the Private key if configured.
- privateKey: Private key string to use to sign the token.
- publicKey: Public key string to use to sign the token.
- projectId: Project ID to generate the Token.
- tokenEndpoint: API Endpoint for the Token Generation. Value is
https://apse1.auth.developer.affinidi.io/auth/oauth2/token
.
Example
// NOTE: set your variables for PAT
const privateKey = '<PRIVATE_KEY_STRING>'
const publicKey = '<PUBLIC_KEY_STRING>'
const passphrase = '<KEY_PAIR_PASSPHRASE>'
const keyId = '<KEY_ID>'
const tokenId = '<PAT_ID>'
const projectId = '<PROJECT_ID>'
const tokenEndpoint = 'https://apse1.auth.developer.affinidi.io/auth/oauth2/token'
const apiGatewayUrl = 'https://apse1.api.affinidi.io'
const authProvider = new AuthProvider({
privateKey,
publicKey,
passphrase,
keyId,
machineUserId,
projectId,
tokenEndpoint,
apiGatewayUrl
})
import affinidi_tdk_auth_provider
stats = {
apiGatewayUrl,
keyId,
tokenId,
passphrase,
privateKey,
publicKey,
projectId,
tokenEndpoint,
}
authProvider = affinidi_tdk_auth_provider.AuthProvider(stats)
fetchProjectScopedToken
Return the generated Project Scoped Token to use for calling the Affinidi Services.
Example
import { AuthProvider } from '@affinidi-tdk/auth-provider'
// NOTE: set your variables for PAT
const privateKey = '<PRIVATE_KEY_STRING>'
const publicKey = '<PUBLIC_KEY_STRING>'
const passphrase = '<KEY_PAIR_PASSPHRASE>'
const keyId = '<KEY_ID>'
const tokenId = '<PAT_ID>'
const projectId = '<PROJECT_ID>'
const tokenEndpoint = 'https://apse1.auth.developer.affinidi.io/auth/oauth2/token'
const apiGatewayUrl = 'https://apse1.api.affinidi.io'
const authProvider = new AuthProvider({
privateKey,
publicKey,
passphrase,
keyId,
machineUserId,
projectId,
tokenEndpoint,
apiGatewayUrl
})
const projectScopedToken = await authProvider.fetchProjectScopedToken()
import affinidi_tdk_auth_provider
stats = {
apiGatewayUrl,
keyId,
tokenId,
passphrase,
privateKey,
publicKey,
projectId,
tokenEndpoint,
}
authProvider = affinidi_tdk_auth_provider.AuthProvider(stats)
projectScopedToken = authProvider.fetch_project_scoped_token()
createIotaToken
Create an Affinidi Iota Framework token to integrate your application and initialise requests.
Example
import { AuthProvider } from '@affinidi-tdk/auth-provider'
// NOTE: set your variables for PAT
const privateKey = '<PRIVATE_KEY_STRING>'
const publicKey = '<PUBLIC_KEY_STRING>'
const passphrase = '<KEY_PAIR_PASSPHRASE>'
const keyId = '<KEY_ID>'
const tokenId = '<PAT_ID>'
const projectId = '<PROJECT_ID>'
const tokenEndpoint = 'https://apse1.auth.developer.affinidi.io/auth/oauth2/token'
const apiGatewayUrl = 'https://apse1.api.affinidi.io'
const authProvider = new AuthProvider({
privateKey,
publicKey,
passphrase,
keyId,
machineUserId,
projectId,
tokenEndpoint,
apiGatewayUrl
})
const jwt = await authProvider.createIotaToken('Configuration ID')
import affinidi_tdk_auth_provider
stats = {
apiGatewayUrl,
keyId,
tokenId,
passphrase,
privateKey,
publicKey,
projectId,
tokenEndpoint,
}
authProvider = affinidi_tdk_auth_provider.AuthProvider(stats)
jwt = authProvider.create_iota_token('Configuration ID')
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.