oauth

package
v0.0.1 Latest Latest
Warning

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

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

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