oauth

package
v0.3.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 10 Imported by: ? modules, 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 HubSpot's provider-owned OAuth2 protocol boundary.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidGrant identifies rejected authorization codes and refresh tokens.
	ErrInvalidGrant = xerror.New(xerror.KindInvalidInput, "HUBSPOT_INVALID_GRANT", "HubSpot OAuth invalid grant")
)

Functions

This section is empty.

Types

type AuthorizationURLParams

type AuthorizationURLParams struct {
	State          string
	Scopes         []string
	OptionalScopes []string
}

AuthorizationURLParams contains the state and scopes for a consent request.

type Client

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

Client performs HubSpot consent, token, refresh, and revocation requests.

func New

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

New validates deployment-owned provider configuration and constructs an OAuth client.

func (*Client) AuthorizationURL

func (c *Client) AuthorizationURL(params AuthorizationURLParams) (string, error)

AuthorizationURL builds the HubSpot consent URL for the supplied state and scopes.

func (*Client) ExchangeCode

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

ExchangeCode exchanges a one-time authorization code for a normalized token set.

func (*Client) Refresh

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

Refresh exchanges a refresh token while preserving HubSpot's granted scopes.

func (*Client) Revoke

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

Revoke revokes a refresh token, accepting HubSpot's idempotent not-found response.

func (*Client) ScopePlan

func (*Client) ScopePlan() ScopePlan

ScopePlan returns HubSpot's mandatory OAuth scope and least-privilege CRM read/write plan.

type Config

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

Config contains deployment-owned HubSpot OAuth client settings.

type ScopePlan

type ScopePlan struct {
	Required []string
	Optional []string
}

ScopePlan describes the required and optional scopes for a HubSpot grant.

type TokenSet

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

TokenSet is HubSpot's normalized OAuth token response.

Jump to

Keyboard shortcuts

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