dcr

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DCRClientName is the client name used during registration
	// Matches datadog-api-claude-plugin for compatibility
	DCRClientName = "datadog-api-claude-plugin"
)

Constants from TypeScript PR #84 for compatibility

Variables

View Source
var DCRRedirectPorts = []int{8000, 8080, 8888, 9000}

DCRRedirectPorts are the specific ports to register for OAuth callbacks Must match TypeScript PR #84 for compatibility

Functions

func GetRedirectURIs

func GetRedirectURIs() []string

GetRedirectURIs returns the standard redirect URIs for the given ports

Types

type Client

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

Client handles Dynamic Client Registration with Datadog

func NewClient

func NewClient(site string) *Client

NewClient creates a new DCR client

func NewClientWithHTTPClient

func NewClientWithHTTPClient(site string, httpClient *http.Client) *Client

NewClientWithHTTPClient creates a new DCR client with a custom HTTP client This is primarily used for testing with mock servers

func (*Client) ExchangeCode

func (c *Client) ExchangeCode(code, redirectURI, codeVerifier string, creds *types.ClientCredentials) (*types.TokenSet, error)

ExchangeCode exchanges an authorization code for tokens Matches TypeScript PR #84 - uses form-encoded data, no client_secret (public client)

func (*Client) RefreshToken

func (c *Client) RefreshToken(refreshToken string, creds *types.ClientCredentials) (*types.TokenSet, error)

RefreshToken refreshes an access token using a refresh token Matches TypeScript PR #84 - uses form-encoded data, no client_secret (public client)

func (*Client) Register

func (c *Client) Register(redirectURI string, scopes []string) (*types.ClientCredentials, error)

Register performs Dynamic Client Registration Registers all standard redirect URIs (ports 8000, 8080, 8888, 9000) Matches TypeScript PR #84 behavior for compatibility

type RegistrationRequest

type RegistrationRequest struct {
	ClientName   string   `json:"client_name"`
	RedirectURIs []string `json:"redirect_uris"`
	GrantTypes   []string `json:"grant_types"`
}

RegistrationRequest represents a DCR registration request (RFC 7591) Matches TypeScript PR #84 format for compatibility

type RegistrationResponse

type RegistrationResponse struct {
	ClientID                string   `json:"client_id"`
	ClientName              string   `json:"client_name"`
	RedirectURIs            []string `json:"redirect_uris"`
	TokenEndpointAuthMethod string   `json:"token_endpoint_auth_method"`
	GrantTypes              []string `json:"grant_types"`
	Scope                   string   `json:"scope,omitempty"`
}

RegistrationResponse represents a DCR registration response Matches TypeScript PR #84 format for compatibility Note: Public clients (token_endpoint_auth_method: 'none') don't receive client_secret

type TokenRequest

type TokenRequest struct {
	GrantType    string `json:"grant_type"`
	Code         string `json:"code,omitempty"`
	RedirectURI  string `json:"redirect_uri,omitempty"`
	ClientID     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
	CodeVerifier string `json:"code_verifier,omitempty"`
	RefreshToken string `json:"refresh_token,omitempty"`
}

TokenRequest represents an OAuth2 token request

type TokenResponse

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

TokenResponse represents an OAuth2 token response

Jump to

Keyboard shortcuts

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