auth

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package auth provides MSAL-based authentication for Microsoft Graph.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StatusJSON

func StatusJSON(ctx context.Context, client *Client) ([]byte, error)

StatusJSON returns the status as JSON bytes.

Types

type Client

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

Client wraps the MSAL public client application with session management.

func NewClient

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

NewClient creates a new MSAL auth client.

func (*Client) AcquireToken

func (c *Client) AcquireToken(ctx context.Context, scopes []string, forceDeviceCode bool) (string, error)

AcquireToken attempts silent auth first, then falls back to interactive/device code.

func (*Client) AcquireTokenDeviceCode

func (c *Client) AcquireTokenDeviceCode(ctx context.Context, scopes []string) (string, error)

AcquireTokenDeviceCode uses the device code flow for authentication.

func (*Client) AcquireTokenInteractive

func (c *Client) AcquireTokenInteractive(ctx context.Context, scopes []string) (string, error)

AcquireTokenInteractive opens the system browser for authentication.

func (*Client) AcquireTokenSilent

func (c *Client) AcquireTokenSilent(ctx context.Context, scopes []string) (string, error)

AcquireTokenSilent attempts to get a token from the cache without user interaction.

func (*Client) AcquireTokenWithExtraScopes

func (c *Client) AcquireTokenWithExtraScopes(ctx context.Context, existingScopes, extraScopes []string, forceDeviceCode bool) (string, error)

AcquireTokenWithExtraScopes re-authenticates with additional scopes for incremental consent.

func (*Client) GetAccounts

func (c *Client) GetAccounts(ctx context.Context) ([]public.Account, error)

GetAccounts returns the accounts currently in the cache.

func (*Client) SignOut

func (c *Client) SignOut() error

SignOut clears the session cache.

func (*Client) Status

func (c *Client) Status(ctx context.Context) (map[string]interface{}, error)

Status returns information about the current auth state.

type SessionData

type SessionData struct {
	Account  public.Account `json:"account"`
	TenantID string         `json:"tenantId"`
	ClientID string         `json:"clientId"`
	Scopes   []string       `json:"scopes"`
}

SessionData stores the current auth session state.

Jump to

Keyboard shortcuts

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