oauth

package
v0.20.3 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildAuthURL

func BuildAuthURL(cfg *Config) (string, string)

BuildAuthURL returns the GitHub OAuth authorization URL and a random state token.

func ExchangeCode

func ExchangeCode(ctx context.Context, cfg *Config, code string) (string, error)

ExchangeCode exchanges an authorization code for an access token.

Types

type Config

type Config struct {
	ClientID     string
	ClientSecret string
	RedirectURL  string
	AuthURL      string // override for testing
	TokenURL     string // override for testing
	UserURL      string // override for testing
	EmailsURL    string // override for testing
}

Config holds GitHub OAuth App credentials.

type GitHubUser

type GitHubUser struct {
	ID        int64  `json:"id"`
	Login     string `json:"login"`
	Email     string `json:"email"`
	AvatarURL string `json:"avatar_url"`
}

GitHubUser represents the authenticated GitHub user profile.

func FetchUser

func FetchUser(ctx context.Context, cfg *Config, token string) (*GitHubUser, error)

FetchUser retrieves the authenticated user's GitHub profile. The token is used only for this call and should be discarded afterward.

Jump to

Keyboard shortcuts

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