Go SDK

Official OAuth42 SDK for Go. Idiomatic Go client for OAuth 2.0 and OpenID Connect.

Installation

Install the OAuth42 SDK using go get:

go get github.com/oauth42/go-sdk

Requirements

Go 1.21 or higher. The SDK uses generics and other modern Go features.

Quick Start

Initialize Client

package main

import (
    "github.com/oauth42/go-sdk"
    "os"
)

func main() {
    client := oauth42.NewClient(&oauth42.Config{
        ClientID:     os.Getenv("OAUTH42_CLIENT_ID"),
        ClientSecret: os.Getenv("OAUTH42_CLIENT_SECRET"),
        RedirectURI:  "https://yourapp.com/callback",
    })
}

Authentication

// Start authorization
authData, err := client.Authorize(&oauth42.AuthorizeParams{
    Scope: []string{"openid", "profile", "email"},
})

// Exchange code for tokens
tokens, err := client.ExchangeCode(&oauth42.ExchangeParams{
    Code:         code,
    CodeVerifier: codeVerifier,
})

Next Steps