oauth

package
v0.3.0-rc.7-linux-arm64 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package oauth implements GitLab's provider-owned OAuth2 protocol boundary.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidGrant = xerror.New(xerror.KindInvalidInput, "GITLAB_INVALID_GRANT", "GitLab OAuth invalid grant")

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(config Config) (*Client, error)

func (*Client) AuthorizationURL

func (c *Client) AuthorizationURL(state string, scopes []string) (string, error)

func (*Client) ExchangeCode

func (c *Client) ExchangeCode(ctx context.Context, code string) (TokenSet, error)

func (*Client) GetProject

func (c *Client) GetProject(ctx context.Context, accessToken, projectID string) (Project, error)

GetProject resolves one stable GitLab project ID through the authenticated grant.

func (*Client) ListProjects

func (c *Client) ListProjects(ctx context.Context, accessToken string) ([]Project, error)

ListProjects returns a bounded list of projects visible to the authenticated grant.

func (*Client) Refresh

func (c *Client) Refresh(ctx context.Context, refreshToken string) (TokenSet, error)

func (*Client) Revoke

func (c *Client) Revoke(ctx context.Context, accessToken string) error

type Config

type Config struct {
	AllowPlaintext bool
	ClientID       string
	ClientSecret   string
	RedirectURI    string
	BaseURL        string
}

type Project

type Project struct {
	ID            int64  `json:"id"`
	Name          string `json:"name"`
	PathWithNS    string `json:"path_with_namespace"`
	WebURL        string `json:"web_url"`
	HTTPURLToRepo string `json:"http_url_to_repo"`
	DefaultBranch string `json:"default_branch"`
}

Project is safe GitLab project identity plus the provider-owned native Git endpoint.

type TokenSet

type TokenSet struct {
	AccessToken  string
	RefreshToken string
	ExpiresAt    time.Time
	Scopes       []string
	AccountID    string
	AccountName  string
	AccountEmail string
}

Jump to

Keyboard shortcuts

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