Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

authdog/sdk

Repository files navigation

Authdog SDK

Official SDKs for Authdog authentication and user management platform.

SDK Health Status

Available SDKs

Core SDKs

Additional Languages

Functional Languages

Scripting & Other

Quick Start Examples

Python SDK

from authdog import AuthdogClient

# Initialize the client
client = AuthdogClient("https://api.authdog.com")

# Get user information
user_info = client.get_userinfo("your-access-token")
print(f"User: {user_info['user']['displayName']}")

# Always close the client
client.close()

Node.js SDK

import { AuthdogClient } from '@authdog/node-sdk';

// Initialize the client
const client = new AuthdogClient({
baseUrl: 'https://api.authdog.com'
});

// Get user information
const userInfo = await client.getUserInfo('your-access-token');
console.log(`User: ${userInfo.user.displayName}`);

Go SDK

package main

import (
"context"
"fmt"
"log"

"github.com/authdog/go-sdk"
)

func main() {
// Initialize the client
client := authdog.NewClient(authdog.ClientConfig{
BaseURL: "https://api.authdog.com",
APIKey: "your-api-key", // Optional
})

// Get user information
ctx := context.Background()
userInfo, err := client.GetUserInfo(ctx, "your-access-token")
if err != nil {
log.Fatal(err)
}

fmt.Printf("User: %s\n", userInfo.User.DisplayName)
}

Kotlin SDK

import com.authdog.sdk.*
import kotlinx.coroutines.runBlocking

fun main() = runBlocking {
// Initialize the client
val client = AuthdogClient(
AuthdogClientConfig(
baseUrl = "https://api.authdog.com",
apiKey = "your-api-key" // Optional
)
)

// Get user information
val userInfo = client.getUserInfo("your-access-token")
println("User: ${userInfo.user.displayName}")
}

Rust SDK

use authdog::{AuthdogClient, AuthdogClientConfig};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialize the client
let config = AuthdogClientConfig {
base_url: "https://api.authdog.com".to_string(),
api_key: Some("your-api-key".to_string()), // Optional
..Default::default()
};

let client = AuthdogClient::new(config)?;

// Get user information
let user_info = client.get_user_info("your-access-token").await?;
println!("User: {}", user_info.user.display_name);

Ok(())
}

PHP SDK

getUserInfo('your-access-token'); echo "User: " . $userInfo->user->displayName . "\n"; } catch (AuthenticationException $e) { echo "Authentication failed: " . $e->getMessage() . "\n"; } catch (ApiException $e) { echo "API error: " . $e->getMessage() . "\n"; } // Always close the client $client->close();">

require_once 'vendor/autoload.php';

use Authdog\AuthdogClient;
use Authdog\Exceptions\AuthenticationException;
use Authdog\Exceptions\ApiException;

// Initialize the client
$client = new AuthdogClient('https://api.authdog.com');

try {
// Get user information
$userInfo = $client->getUserInfo('your-access-token');
echo "User: " . $userInfo->user->displayName . "\n";
} catch (AuthenticationException $e) {
echo "Authentication failed: " . $e->getMessage() . "\n";
} catch (ApiException $e) {
echo "API error: " . $e->getMessage() . "\n";
}

// Always close the client
$client->close();

C# SDK

using Authdog;
using Authdog.Exceptions;

// Initialize the client
var client = new AuthdogClient("https://api.authdog.com");

try
{
// Get user information
var userInfo = await client.GetUserInfoAsync("your-access-token");
Console.WriteLine($"User: {userInfo.User.DisplayName}");
}
catch (AuthenticationException ex)
{
Console.WriteLine($"Authentication failed: {ex.Message}");
}
catch (ApiException ex)
{
Console.WriteLine($"API error: {ex.Message}");
}
finally
{
// Always dispose the client
client.Dispose();
}

C++ SDK

#include <iostream>
#include "authdog/authdog_client.h"
#include "authdog/exceptions.h"

int main() {
try {
// Initialize the client
authdog::AuthdogClient client("https://api.authdog.com");

// Get user information
auto userInfo = client.getUserInfo("your-access-token");
std::cout << "User: " << userInfo.user.displayName << std::endl;

// Close the client
client.close();

} catch (const authdog::AuthenticationException& e) {
std::cerr << "Authentication failed: " << e.what() << std::endl;
} catch (const authdog::ApiException& e) {
std::cerr << "API error: " << e.what() << std::endl;
}

return 0;
}

Elixir SDK

# Initialize the client
client = Authdog.Client.new("https://api.authdog.com")

# Get user information
case Authdog.Client.get_user_info(client, "your-access-token") do
{:ok, user_info} ->
IO.puts("User: #{user_info.user.display_name}")
{:error, :authentication_error, message} ->
IO.puts("Authentication failed: #{message}")
{:error, :api_error, message} ->
IO.puts("API error: #{message}")
end

Java SDK

import com.authdog.AuthdogClient;
import com.authdog.exceptions.AuthenticationException;
import com.authdog.exceptions.ApiException;

// Initialize the client
try (AuthdogClient client = new AuthdogClient("https://api.authdog.com")) {
// Get user information
UserInfoResponse userInfo = client.getUserInfo("your-access-token");
System.out.println("User: " + userInfo.getUser().getDisplayName());
} catch (AuthenticationException e) {
System.err.println("Authentication failed: " + e.getMessage());
} catch (ApiException e) {
System.err.println("API error: " + e.getMessage());
}

Scala SDK

import com.authdog.AuthdogClient
import com.authdog.exceptions.{AuthenticationException, ApiException}

// Initialize the client
val client = AuthdogClient("https://api.authdog.com")

try {
// Get user information
val userInfo = client.getUserInfo("your-access-token")
println(s"User: ${userInfo.user.displayName}")
} catch {
case e: AuthenticationException =>
println(s"Authentication failed: ${e.getMessage}")
case e: ApiException =>
println(s"API error: ${e.getMessage}")
} finally {
client.close()
}

Common Lisp SDK

(ql:quickload :authdog)
(use-package :authdog)

;; Initialize the client
(defvar *client* (make-authdog-client "https://api.authdog.com"))

;; Get user information
(handler-case
(let ((user-info (get-user-info *client* "your-access-token")))
(format t "User: ~A~%" (user-display-name (user-info-response-user user-info))))
(authentication-error (e)
(format t "Authentication failed: ~A~%" (authdog-error-message e)))
(api-error (e)
(format t "API error: ~A~%" (authdog-error-message e))))

Clojure SDK

(require '[authdog.core :as authdog]
'[authdog.exceptions :as ex])

;; Initialize the client
(def client (authdog/make-client "https://api.authdog.com"))

;; Get user information
(try
(let [user-info (authdog/get-user-info client "your-access-token")]
(println "User:" (:display-name (:user user-info))))
(catch clojure.lang.ExceptionInfo e
(cond
(ex/authentication-error? e)
(println "Authentication failed:" (.getMessage e))

(ex/api-error? e)
(println "API error:" (.getMessage e)))))

Swift SDK

import AuthdogSwiftSDK

// Initialize the client
let client = AuthdogClient(baseURL: "https://api.authdog.com")

// Get user information (async/await)
Task {
do {
let userInfo = try await client.getUserInfo(accessToken: "your-access-token")
print("User: \(userInfo.user.displayName)")
} catch AuthdogError.authenticationFailed(let message) {
print("Authentication failed: \(message)")
} catch AuthdogError.apiError(let message) {
print("API error: \(message)")
}
}

// Get user information (completion handler)
client.getUserInfo(accessToken: "your-access-token") { result in
switch result {
case .success(let userInfo):
print("User: \(userInfo.user.displayName)")
case .failure(let error):
print("Error: \(error.localizedDescription)")
}
}

Zig SDK

const authdog = @import("authdog");

// Initialize the client
var client = authdog.AuthdogClient.init("https://api.authdog.com", .{});

// Get user information
const user_info = client.getUserInfo("your-access-token") catch |err| switch (err) {
error.AuthenticationFailed => {
std.debug.print("Authentication failed\n", .{});
return;
},
error.ApiError => {
std.debug.print("API error\n", .{});
return;
},
else => {
std.debug.print("Unexpected error: {}\n", .{err});
return;
},
};

std.debug.print("User: {s}\n", .{user_info.user.display_name});

Additional SDKs

These SDKs are also available with full documentation in their respective directories.

Features

  • User Information: Get detailed user information including profile data, emails, photos, and verification status
  • Authentication: Handle authentication errors and token validation
  • Type Safety: Full type support across all languages (TypeScript, Go, Kotlin, Rust)
  • Error Handling: Structured error handling with specific exception types
  • Modern APIs: Built with modern HTTP clients and async/await support
  • Cross-Platform: Available for Python, Node.js, Go, Kotlin, Rust, PHP, C#, C++, Elixir, Java, Scala, Common Lisp, Clojure, Swift, Zig, and R

API Endpoints

All SDKs support the following endpoint:

GET /v1/userinfo

Retrieve user information using an access token.

Authentication: Bearer token required

Response Structure:

{
"meta": {
"code": 200,
"message": "Success"
},
"session": {
"remainingSeconds": 56229
},
"user": {
"id": "user-id",
"externalId": "external-id",
"userName": "username",
"displayName": "Display Name",
"emails": [{"value": "email@example.com", "type": null}],
"photos": [{"value": "https://example.com/photo.jpg", "type": "photo"}],
"names": {
"familyName": "Last",
"givenName": "First"
},
"verifications": [...],
"provider": "google-oauth20",
"environmentId": "env-id"
}
}

Error Handling

All SDKs provide structured error handling:

  • AuthenticationError: Raised when authentication fails (401 responses)
  • APIError: Raised when API requests fail
  • Base AuthdogError: Common base class for all SDK errors

Development

Each SDK has its own development setup. See the individual README files:

Contributing

Please see our Contributing Guide for details on how to contribute to the SDKs.

License

MIT License - see LICENSE for details.

About

self-explanatory

Topics

Resources

Readme

License

MIT license

Contributing

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors