graph

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

View Source
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

func New(tenantID, clientID, tokenPath string) (*Client, error)

New constructs a Client for the given Entra public-client app. tokenPath is where the MSAL token cache is persisted.

func (*Client) Account

func (c *Client) Account(ctx context.Context) (string, error)

Account returns the cached account's preferred username, or "" if none.

func (*Client) ClearPreferredPresence

func (c *Client) ClearPreferredPresence(ctx context.Context) error

ClearPreferredPresence removes any preferred presence, restoring automatic presence behavior.

func (*Client) GetPresence

func (c *Client) GetPresence(ctx context.Context) (availability, activity string, err error)

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

func (c *Client) Login(ctx context.Context, prompt func(message string)) error

Login performs the device-code flow. prompt is called with the user-facing instruction message (URL + code). On success the token is cached.

func (*Client) Logout

func (c *Client) Logout(ctx context.Context) error

Logout removes the cached account(s).

func (*Client) SetPreferredPresence

func (c *Client) SetPreferredPresence(ctx context.Context, availability, activity, expiration string) error

SetPreferredPresence sets a sticky preferred presence for the signed-in user.

Jump to

Keyboard shortcuts

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