Quick Start Guide
Supported languages
Go
Python
Rust
Typescript
Step 1: Install the SDK
go get github.com/melvinodsa/go-iam-sdk/golang
Step 2: Initialize the SDK
package main
import (
"context"
"log"
goiam "github.com/melvinodsa/go-iam-sdk/golang"
)
func main() {
service := goiam.NewService(
"https://your-go-iam-server.com",
"your-client-id",
"your-client-secret"
)
// Ready to use!
}
Step 3: Implement Authentication
Verify Authentication Code
ctx := context.Background()
token, err := service.Verify(ctx, "auth-code")
if err != nil {
log.Fatalf("Failed to verify: %v", err)
}
fmt.Println("Access Token:", token)}
Fetch User Information
user, err := service.Me(ctx, token)
if err != nil {
log.Fatalf("Failed to fetch user: %v", err)
}
fmt.Printf("User: %+v", user)
Advanced Features
Resource Management
resource := &golang.Resource{
ID: "resource-id",
Name: "User Dashboard",
Description: "Main user dashboard resource",
Tags: []string{"dashboard", "user"},
}
err = service.CreateResource(ctx, resource, "token")
if err != nil {
log.Fatalf("Failed to create resource: %v", err)
}
err = service.DeleteResource(ctx, resource.ID, "token")
if err != nil {
log.Fatalf("Failed to delete resource: %v", err)
}
User object
type User struct {
Id string `json:"id"`
ProjectId string `json:"project_id"`
Name string `json:"name"`
Email string `json:"email"`
Phone string `json:"phone"`
Enabled bool `json:"enabled"`
ProfilePic string `json:"profile_pic"`
LinkedClientId string `json:"linked_client_id,omitempty"`
Expiry *time.Time `json:"expiry"`
Roles map[string]UserRole `json:"roles"`
Resources map[string]UserResource `json:"resources"`
Policies map[string]UserPolicy `json:"policies"`
CreatedAt *time.Time `json:"created_at"`
CreatedBy string `json:"created_by"`
UpdatedAt *time.Time `json:"updated_at"`
UpdatedBy string `json:"updated_by"`
}
type UserPolicy struct {
Name string `json:"name"`
Mapping UserPolicyMapping `json:"mapping,omitempty"`
}
type UserPolicyMapping struct {
Arguments map[string]UserPolicyMappingValue `json:"arguments,omitempty"`
}
type UserPolicyMappingValue struct {
Static string `json:"static,omitempty"`
}
type UserRole struct {
Id string `json:"id"`
Name string `json:"name"`
}
type UserResource struct {
RoleIds map[string]bool `json:"role_ids"`
PolicyIds map[string]bool `json:"policy_ids"`
Key string `json:"key"`
Name string `json:"name"`
}
Resource object
type Resource struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Key string `json:"key"`
Enabled bool `json:"enabled"`
ProjectId string `json:"project_id"`
CreatedAt *time.Time `json:"created_at"`
CreatedBy string `json:"created_by"`
UpdatedAt *time.Time `json:"updated_at"`
UpdatedBy string `json:"updated_by"`
DeletedAt *time.Time `json:"deleted_at,omitempty"`
}