providers

package
v1.1.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2026 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package providers defines OAuth provider interfaces and user information structures for social authentication.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ClientID     string
	ClientSecret string
	AuthURL      string
	TokenURL     string
	UserInfoURL  string
	Scopes       []string
}

Config represents OAuth provider configuration

type Provider

type Provider interface {
	// GetName returns the provider name (e.g., "github", "discord", "google")
	GetName() string

	// GetAuthURL returns the authorization URL for the provider
	GetAuthURL(state, redirectURI string) string

	// ExchangeCode exchanges an authorization code for an access token
	ExchangeCode(ctx context.Context, code, redirectURI string) (*TokenResponse, error)

	// GetUserInfo fetches user information using the access token
	GetUserInfo(ctx context.Context, accessToken string) (*UserInfo, error)
}

Provider represents an OAuth provider interface

type TokenResponse

type TokenResponse struct {
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type"`
	RefreshToken string `json:"refresh_token,omitempty"`
	ExpiresIn    int    `json:"expires_in,omitempty"`
	Scope        string `json:"scope,omitempty"`
}

TokenResponse represents the OAuth token response

type UserInfo

type UserInfo struct {
	ID         string `json:"id"`
	Username   string `json:"username"`
	Email      string `json:"email"`
	Name       string `json:"name"`
	AvatarURL  string `json:"avatar_url"`
	Provider   string `json:"provider"`
	ProviderID string `json:"provider_id"`
}

UserInfo represents user information from the provider

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL