Documentation
¶
Overview ¶
Package graph wraps Microsoft Graph authentication (MSAL device-code flow with a persistent token cache) and the presence "preferred presence" endpoints.
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) Account(ctx context.Context) (string, error)
- func (c *Client) ClearPreferredPresence(ctx context.Context) error
- func (c *Client) GetPresence(ctx context.Context) (availability, activity string, err error)
- func (c *Client) Login(ctx context.Context, prompt func(message string)) error
- func (c *Client) Logout(ctx context.Context) error
- func (c *Client) SetPreferredPresence(ctx context.Context, availability, activity, expiration string) error
Constants ¶
const Scope = "https://graph.microsoft.com/Presence.ReadWrite"
Scope is the delegated permission required to set presence. Note: this permission requires tenant ADMIN consent.
Variables ¶
var ErrLoginRequired = errors.New("graph: login required (run `vigil auth login`)")
ErrLoginRequired is returned when no cached account can produce a token silently and an interactive `auth login` is needed.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client authenticates against Entra ID and calls the presence endpoints.
func New ¶
New constructs a Client for the given Entra public-client app. tokenPath is where the MSAL token cache is persisted.
func (*Client) ClearPreferredPresence ¶
ClearPreferredPresence removes any preferred presence, restoring automatic presence behavior.
func (*Client) GetPresence ¶
GetPresence reads the signed-in user's current presence. It doubles as a permission check: a 403 indicates Presence.ReadWrite is not admin-consented.
func (*Client) Login ¶
Login performs the device-code flow. prompt is called with the user-facing instruction message (URL + code). On success the token is cached.