oauth

OAuth 2.0 client library for Kit

Files

FileDescription
kit.tomlPackage manifest with metadata and dependencies
src/oauth.kitOAuth flows, provider presets, and token management
tests/oauth.test.kitTests for providers, URLs, state, and expiration
examples/client-credentials.kitMachine-to-machine auth without user interaction
examples/github.kitAuthorization code flow with GitHub API
LICENSEMIT license file

Architecture

Authorization Code Flow

sequenceDiagram participant App participant User participant AuthServer participant ResourceServer App->>User: Redirect to Auth URL User->>AuthServer: Login & Consent AuthServer->>App: Authorization Code App->>AuthServer: Exchange Code + Secret AuthServer->>App: Access Token App->>ResourceServer: API Request + Token ResourceServer->>App: Protected Resource

Client Credentials Flow

sequenceDiagram participant App participant AuthServer participant ResourceServer App->>AuthServer: Client ID + Secret AuthServer->>App: Access Token App->>ResourceServer: API Request + Token ResourceServer->>App: Protected Resource

Dependencies

  • base64

Installation

kit add gitlab.com/kit-lang/packages/kit-oauth.git

Usage

import Kit.Oauth

License

MIT License - see LICENSE for details.

Exported Functions & Types

authorize-url

OAuthConfig -> String -> String

authorize-url-pkce

OAuthConfig -> String -> String -> String

exchange-code

OAuthConfig -> String -> Result TokenResponse String

exchange-code-pkce

OAuthConfig -> String -> String -> Result TokenResponse String

refresh-token

OAuthConfig -> String -> Result TokenResponse String

client-credentials

OAuthConfig -> Result TokenResponse String

get

String -> String -> Result HttpResponse String

post

String -> String -> String -> Result HttpResponse String

github

String -> String -> String -> List String -> OAuthConfig

google

String -> String -> String -> List String -> OAuthConfig

microsoft

String -> String -> String -> String -> List String -> OAuthConfig

discord

String -> String -> String -> List String -> OAuthConfig

slack

String -> String -> String -> List String -> OAuthConfig

gitlab

String -> String -> String -> List String -> OAuthConfig

custom

String -> String -> String -> String -> String -> List String -> OAuthConfig

generate-state

String

is-expired?

TokenResponse -> Int -> Bool