Go IAM SDK

September 19, 2025 ยท View on GitHub

The Go IAM SDK is a comprehensive multi-language library for integrating with the Go IAM server. It provides methods for authentication, user management, and resource creation across multiple programming languages and frameworks.

Available SDKs:

  • Go - Server-side applications
  • TypeScript - Node.js and browser applications
  • Python - Python applications with async support
  • Rust - High-performance applications
  • React - Frontend React applications with Context, hooks, and components

โœ… Admin UI: go-iam-ui
๐Ÿณ Docker Setup: go-iam-docker
๐Ÿ” Backend: go-iam
๐Ÿ“ฆ SDK: go-iam-sdk
๐Ÿš€ Examples: go-iam-examples

Installation

Go

go get github.com/melvinodsa/go-iam-sdk/golang

TypeScript

npm install @goiam/typescript
# or
pnpm add @goiam/typescript
# or
yarn add @goiam/typescript

Python

pip install goiam-python
# or
poetry add goiam-python
# or
pipenv install goiam-python

Rust

Add to your Cargo.toml:

[dependencies]
goiam = "0.1.0"
tokio = { version = "1.0", features = ["full"] }

React

npm install @goiam/react
# or
pnpm add @goiam/react
# or
yarn add @goiam/react

Usage

Go

Initialize the Service

import (
	"context"
	goiam "github.com/melvinodsa/go-iam-sdk/golang"
)

func main() {
	service := goiam.NewService("https://go-iam.example.com", "your-client-id", "your-secret")
	// Use the service instance for API calls
}

Verify Authentication Code

ctx := context.Background()
token, err := service.Verify(ctx, "auth-code")
if err != nil {
	log.Fatalf("Failed to verify code: %v", err)
}
fmt.Println("Access Token:", token)

Fetch Current User Information

user, err := service.Me(ctx, token)
if err != nil {
	log.Fatalf("Failed to fetch user information: %v", err)
}
fmt.Printf("User: %+v\n", user)

Create a Resource

resource := &golang.Resource{
	ID:          "resource-id",
	Name:        "Resource Name",
	Description: "Resource Description",
	Tags:        []string{"tag1", "tag2"},
}

err = service.CreateResource(ctx, resource)
if err != nil {
	log.Fatalf("Failed to create resource: %v", err)
}
fmt.Println("Resource created successfully")

TypeScript

npm version npm downloads

Initialize the SDK

import { GoIamSdk } from "@goiam/typescript";

const sdk = new GoIamSdk(
  "https://go-iam.example.com",
  "your-client-id",
  "your-secret"
);

Verify Authentication Code

const token = await sdk.verify("auth-code");
console.log("Access Token:", token);

Fetch Current User Information

const user = await sdk.me(token);
console.log("User:", user);

Create a Resource

const resource = {
  id: "resource-id",
  name: "Resource Name",
  description: "Resource Description",
  key: "resource-key",
  enabled: true,
  projectId: "project-id",
  createdBy: "creator",
  updatedBy: "updater",
};

await sdk.createResource(resource, token);
console.log("Resource created successfully");

Python

PyPI version Python versions

Initialize the SDK

from goiam import new_service

service = new_service(
    base_url="https://go-iam.example.com",
    client_id="your-client-id",
    secret="your-secret"
)

Verify Authentication Code

try:
    token = service.verify("auth-code")
    print(f"Access Token: {token}")
except Exception as error:
    print(f"Failed to verify code: {error}")

Fetch Current User Information

try:
    user = service.me(token)
    print(f"User: {user.name} ({user.email})")
except Exception as error:
    print(f"Failed to fetch user information: {error}")

Create a Resource

from goiam import Resource

resource = Resource(
    id="resource-id",
    name="Resource Name",
    description="Resource Description",
    key="resource-key",
    enabled=True,
    project_id="project-id",
    created_by="creator",
    updated_by="updater"
)

try:
    service.create_resource(resource, token)
    print("Resource created successfully")
except Exception as error:
    print(f"Failed to create resource: {error}")

Rust

Crates.io Documentation

Initialize the SDK

use goiam::{new_service, Service};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let service = new_service(
        "https://go-iam.example.com".to_string(),
        "your-client-id".to_string(),
        "your-secret".to_string(),
    );

    // SDK usage here...
    Ok(())
}

Verify Authentication Code

match service.verify("auth-code").await {
    Ok(token) => println!("Access Token: {}", token),
    Err(error) => eprintln!("Failed to verify code: {}", error),
}

Fetch Current User Information

match service.me(&token).await {
    Ok(user) => println!("User: {} ({})", user.name, user.email),
    Err(error) => eprintln!("Failed to fetch user information: {}", error),
}

Create a Resource

use goiam::Resource;

let resource = Resource::new("resource-id".to_string(), "Resource Name".to_string());

match service.create_resource(&resource, &token).await {
    Ok(_) => println!("Resource created successfully"),
    Err(error) => eprintln!("Failed to create resource: {}", error),
}

React

npm version npm downloads

Setup Provider

import React from "react";
import { GoIamProvider, createGoIamConfig } from "@goiam/react";

const config = createGoIamConfig({
  baseUrl: "https://go-iam.example.com",
  clientId: "your-client-id",
  redirectUrl: "https://your-app.com/callback",
});

function App() {
  return (
    <GoIamProvider config={config}>
      <YourApp />
    </GoIamProvider>
  );
}

Authentication Hook

import { useGoIam } from "@goiam/react";

function LoginButton() {
  const { isAuthenticated, user, login, logout, isLoading } = useGoIam();

  if (isLoading) return <div>Loading...</div>;

  if (isAuthenticated) {
    return (
      <div>
        <p>Welcome, {user?.name || user?.email}!</p>
        <button onClick={logout}>Logout</button>
      </div>
    );
  }

  return <button onClick={login}>Login</button>;
}

Protect Routes

import { AuthGuard } from "@goiam/react";

function ProtectedRoute() {
  return (
    <AuthGuard requiredRoles={["admin"]} redirectToLogin={true}>
      <AdminDashboard />
    </AuthGuard>
  );
}

Repository Structure

This repository contains multiple SDK implementations for different languages and frameworks:

go-iam-sdk/
โ”œโ”€โ”€ golang/          # Go SDK - Server-side applications
โ”œโ”€โ”€ typescript/      # TypeScript SDK - Node.js and browser
โ”œโ”€โ”€ python/          # Python SDK - Python applications
โ”œโ”€โ”€ rust/            # Rust SDK - High-performance applications
โ””โ”€โ”€ react/           # React SDK - React applications with hooks and components

SDK Documentation

Each SDK has its own comprehensive documentation:

  • Go SDK - Server-side Go applications
  • TypeScript SDK - Node.js and browser JavaScript/TypeScript
  • Python SDK - Python applications with asyncio support
  • Rust SDK - High-performance Rust applications
  • React SDK - React applications with Context, hooks, and components
  • Reddit Community - Reddit community for discussions

Features by SDK

FeatureGoTypeScriptPythonRustReact
Authenticationโœ…โœ…โœ…โœ…โœ…
User Managementโœ…โœ…โœ…โœ…โœ…
Resource Managementโœ…โœ…โœ…โœ…N/A
Context ProviderN/AN/AN/AN/Aโœ…
Auth GuardsN/AN/AN/AN/Aโœ…
Role-based Accessโœ…โœ…โœ…โœ…โœ…
TypeScript SupportN/Aโœ…N/AN/Aโœ…
Async/AwaitN/Aโœ…โœ…โœ…โœ…

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes in the appropriate SDK directory
  4. Add tests for your changes
  5. Ensure all tests pass (make test in the SDK directory)
  6. Commit your changes (git commit -m 'Add some amazing feature')
  7. Push to the branch (git push origin feature/amazing-feature)
  8. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.