msgraph

package
v0.0.0-...-5811d3a Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateStateParameter

func GenerateStateParameter() (string, error)

GenerateStateParameter generates a cryptographically secure random state parameter for OAuth

Types

type AuthType

type AuthType int

AuthType represents the type of authentication being used

const (
	// AuthTypeApplication represents client credentials flow (application permissions)
	AuthTypeApplication AuthType = iota
	// AuthTypeDelegated represents delegated flow (user permissions)
	AuthTypeDelegated
)

type Client

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

Client represents the base Microsoft Graph client

func NewClient

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

NewClient creates a new Microsoft Graph client with service credentials (client credentials flow)

func NewClientWithToken

func NewClientWithToken(accessToken string) (*Client, error)

NewClientWithToken creates a new Microsoft Graph client using an existing access token (from auth service)

func NewClientWithUserID

func NewClientWithUserID(config Config, userID string) (*Client, error)

NewClientWithUserID creates a new Microsoft Graph client with service credentials for a specific user

func (*Client) ExchangeCodeForToken

func (c *Client) ExchangeCodeForToken(oauthConfig OAuthConfig, code string) (*TokenResponse, error)

ExchangeCodeForToken exchanges authorization code for access token

func (*Client) GenerateAuthorizationURL

func (c *Client) GenerateAuthorizationURL(oauthConfig OAuthConfig, state string) (string, error)

AuthorizationURL generates the authorization URL for OAuth 2.0 flow

func (*Client) GetGraphClient

func (c *Client) GetGraphClient() *msgraph.GraphServiceClient

GetGraphClient returns the underlying Microsoft Graph client

func (*Client) GetOneNoteDataAsJSON

func (c *Client) GetOneNoteDataAsJSON(ctx context.Context) (*types.DocumentCollection, error)

GetOneNoteDataAsJSON implements the Interface method to get all OneNote pages as JSON array This is the public interface that delegates to the data combination layer

func (*Client) GetUserID

func (c *Client) GetUserID() string

GetUserID returns the user ID for application flow

func (*Client) IsDelegatedAuth

func (c *Client) IsDelegatedAuth() bool

IsDelegatedAuth returns true if the client uses delegated authentication flow

func (*Client) RefreshToken

func (c *Client) RefreshToken(oauthConfig OAuthConfig, refreshToken string) (*TokenResponse, error)

RefreshToken refreshes an expired access token using refresh token

func (*Client) TestAccessToken

func (c *Client) TestAccessToken(accessToken string) error

TestAccessToken tests if an access token is valid by making a request to Microsoft Graph

type ConcurrencyConfig

type ConcurrencyConfig struct {
	MaxSectionWorkers int // Maximum concurrent section fetchers
	MaxContentWorkers int // Maximum concurrent content fetchers
}

ConcurrencyConfig defines limits for concurrent operations

func DefaultConcurrencyConfig

func DefaultConcurrencyConfig() ConcurrencyConfig

DefaultConcurrencyConfig returns sensible defaults for API rate limiting

type Config

type Config struct {
	ClientID      string
	ClientSecret  string
	TenantID      string
	LoginEndpoint string
	Scopes        []string
	// OneNote concurrency configuration
	OneNoteConcurrency *ConcurrencyConfig
}

Config represents the configuration for Microsoft Graph client

type ContentJob

type ContentJob struct {
	PageID     string
	PageTitle  string
	PageIndex  int
	TotalPages int
}

ContentJob represents a content fetching job

type ContentResult

type ContentResult struct {
	PageID  string
	Content []byte
	Error   error
}

ContentResult represents the result of content fetching

type Interface

type Interface interface {
	// OneNote data extraction - returns all OneNote pages as JSON array
	GetOneNoteDataAsJSON(ctx context.Context) (*types.DocumentCollection, error)
}

Interface defines the main interface for Microsoft Graph data extraction services

type OAuthClient

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

OAuthClient represents a client specifically for OAuth operations

func NewOAuthClient

func NewOAuthClient(config OAuthConfig) *OAuthClient

NewOAuthClient creates a new OAuth client

func (*OAuthClient) ExchangeCode

func (oc *OAuthClient) ExchangeCode(code string) (*TokenResponse, error)

ExchangeCode exchanges authorization code for tokens

func (*OAuthClient) GetAuthorizationURL

func (oc *OAuthClient) GetAuthorizationURL(state string) (string, error)

GetAuthorizationURL generates authorization URL

func (*OAuthClient) RefreshAccessToken

func (oc *OAuthClient) RefreshAccessToken(refreshToken string) (*TokenResponse, error)

RefreshAccessToken refreshes access token using refresh token

func (*OAuthClient) TestToken

func (oc *OAuthClient) TestToken(accessToken string) error

TestToken tests if access token is valid

type OAuthConfig

type OAuthConfig struct {
	ClientID     string
	ClientSecret string
	TenantID     string // Use "common" for personal accounts, specific tenant ID for work/school accounts
	RedirectURI  string
	Scopes       []string
}

OAuthConfig represents OAuth configuration for Microsoft Graph

func NewPersonalAccountOAuthConfig

func NewPersonalAccountOAuthConfig(clientID, clientSecret, redirectURI string, scopes []string) OAuthConfig

NewPersonalAccountOAuthConfig creates OAuth config for personal Microsoft accounts

func NewWorkSchoolAccountOAuthConfig

func NewWorkSchoolAccountOAuthConfig(clientID, clientSecret, tenantID, redirectURI string, scopes []string) OAuthConfig

NewWorkSchoolAccountOAuthConfig creates OAuth config for work/school Microsoft accounts

func (OAuthConfig) IsPersonalAccountConfig

func (c OAuthConfig) IsPersonalAccountConfig() bool

IsPersonalAccountConfig returns true if this config is set up for personal accounts

type OneNoteRawData

type OneNoteRawData struct {
	Notebooks []msgraphmodels.Notebookable
	Sections  map[string][]msgraphmodels.OnenoteSectionable
	Pages     map[string][]msgraphmodels.OnenotePageable
	Content   map[string][]byte
}

OneNoteRawData represents raw data fetched from OneNote API

type SectionJob

type SectionJob struct {
	NotebookID    string
	Section       msgraphmodels.OnenoteSectionable
	SectionIndex  int
	TotalSections int
}

SectionJob represents a section processing job

type SectionResult

type SectionResult struct {
	SectionID string
	Pages     []msgraphmodels.OnenotePageable
	Error     error
}

SectionResult represents the result of section processing

type TokenResponse

type TokenResponse struct {
	TokenType    string `json:"token_type"`
	Scope        string `json:"scope"`
	ExpiresIn    int    `json:"expires_in"`
	ExtExpiresIn int    `json:"ext_expires_in"`
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
}

TokenResponse represents the response from the token endpoint

Jump to

Keyboard shortcuts

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