Help us shape the future of Go! Take the 2026 Go Developer Survey

graphapi

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package graphapi is a minimal Microsoft Graph client. It is shaped after internal/cfapi and differs only where Graph forces it to: OAuth2 client credentials instead of a static token, and real HTTP status codes instead of Purelymail's HTTP 200 with an error body.

Index

Constants

View Source
const (
	DefaultGraphBaseURL = "https://graph.microsoft.com/v1.0"
	DefaultLoginBaseURL = "https://login.microsoftonline.com"
)

Variables

This section is empty.

Functions

func List

func List[T any](ctx context.Context, c *Client, path string) ([]T, error)

List reads every page of a Graph collection, following @odata.nextLink.

Types

type APIError

type APIError struct {
	Status  int
	Code    string
	Message string
}

APIError is a Graph error response.

func (*APIError) Error

func (e *APIError) Error() string

type Client

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

func New

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

func (*Client) Do

func (c *Client) Do(ctx context.Context, method, path string, body, result any) error

Do performs one Graph request. path is relative to the Graph base URL and starts with "/". A nil body sends none; a nil result discards the response. Do retries transparently on throttling, honouring Retry-After, up to maxRetries times.

func (*Client) String

func (c *Client) String() string

String is safe to include in an error. It never contains the secret.

type Config

type Config struct {
	TenantID     string
	ClientID     string
	ClientSecret string
	// GraphBaseURL and LoginBaseURL default to the public endpoints. Tests
	// point them at httptest servers.
	GraphBaseURL string
	LoginBaseURL string
	HTTP         *http.Client
}

Jump to

Keyboard shortcuts

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