SDK Authentication
All Newline SDKs use a consistent authentication model based on client-level security configuration.
Authentication Method
Each SDK supports a global security scheme with the following parameters:
programUid/ProgramUidhmacKey/HmacKey
These values are provided when initializing the SDK client.
Configure Authentication
Authentication is configured at the time of SDK client initialization by passing the required security parameters.
TypeScript
import { NewlineSDK } from "newline-ts-sdk";
const newlineSDK = new NewlineSDK({
security: {
programUid: process.env["NEWLINE_PROGRAM_UID"] ?? "",
hmacKey: process.env["NEWLINE_HMAC_KEY"] ?? "",
},
}); Java
import com.newline53.sdk.NewlineSDK;
import com.newline53.sdk.models.components.Security;
NewlineSDK sdk = NewlineSDK.builder()
.security(Security.builder()
.programUid(System.getenv().getOrDefault("PROGRAM_UID", ""))
.hmacKey(System.getenv().getOrDefault("HMAC_KEY", ""))
.build())
.build();.NET
using Newline53.Sdk;
using Newline53.Sdk.Models.Components;
var sdk = new NewlineSDK(security: new Security() {
ProgramUid = "<YOUR_PROGRAM_UID_HERE>",
HmacKey = "<YOUR_HMAC_KEY_HERE>",
});Generate an Authentication Token
After configuring the SDK client, you can generate an authentication token using the generateToken / GenerateToken operation.
TypeScript
const result = await newlineSDK.auth.generateToken();Java
var res = sdk.auth().generateToken().call();.NET
var res = await sdk.Auth.GenerateTokenAsync();generateToken generates an authentication token.
Notes
- Authentication is configured per client instance using the security parameters
- The same security configuration applies to all API operations executed by that client
Updated 9 days ago
