Getting Started
Official Documentation
For detailed explanation of each function, check the authorizer-go pkg.go.dev docs.
Prerequisite: You need an Authorizer instance running. See the deployment guides for setup options.
Authorizer v2 Compatibility
The authorizer-go SDK works with both Authorizer v1 and v2 servers. When using with v2:
- Obtain the
Client IDfrom your v2 server's--client-idflag (set at startup) - The SDK methods remain the same; only the server configuration model has changed
Installation
Step 1: Install authorizer-go SDK
go get github.com/authorizerdev/authorizer-go
Step 2: Initialize authorizer client
Parameters
| Key | Type | Required | Description |
|---|---|---|---|
clientID | string | true | Your unique client identifier (from --client-id flag in v2, or dashboard in v1) |
authorizerURL | string | true | Authorizer server URL |
redirectURL | string | false | Default URL to redirect the user after successful signup / login / forgot password |
extraHeaders | map[string]string | false | Set of headers to pass with each request |
Example
defaultHeaders := map[string]string{}
authorizerClient, err := authorizer.NewAuthorizerClient("YOUR_CLIENT_ID", "YOUR_AUTHORIZER_URL", "OPTIONAL_REDIRECT_URL", defaultHeaders)
if err != nil {
panic(err)
}
Step 3: Use SDK methods
Example: Login
response, err := authorizerClient.Login(&authorizer.LoginInput{
Email: "test@yopmail.com",
Password: "Abc@123",
})
if err != nil {
panic(err)
}
Example: Validate JWT Token
res, err := authorizerClient.ValidateJWTToken(&authorizer.ValidateJWTTokenInput{
TokenType: authorizer.TokenTypeIDToken,
Token: "your-jwt-token",
})
if err != nil {
panic(err)
}
if res.IsValid {
// Token is valid
}
Available Methods
The SDK provides the following methods:
Login-- Authenticate with email and passwordSignup-- Register a new userVerifyEmail-- Verify user emailForgotPassword-- Initiate forgot password flowResetPassword-- Reset password with tokenGetProfile-- Get user profileUpdateProfile-- Update user profileMagicLinkLogin-- Login with magic linkValidateJWTToken-- Validate a JWT tokenGetSession-- Get current sessionRevokeToken-- Revoke a tokenLogout-- Logout userValidateSession-- Validate a session