From 49909037dba92fda0f599df4c8a83c4223dad699 Mon Sep 17 00:00:00 2001 From: Adam French Date: Tue, 22 Sep 2026 22:55:35 +0100 Subject: [PATCH] Document Microsoft Graph email auth env vars; newest bookmarks first Co-Authored-By: Claude Code --- .env.example | 21 ++++++++++++++++++++- backend/graph/bookmark.resolvers.go | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index 289298d..6679b7a 100644 --- a/.env.example +++ b/.env.example @@ -59,8 +59,27 @@ GITEA_RUNNER_NAME=pi-runner GITEA_RUNNER_REGISTRATION_TOKEN= # --- Email ingest (backend) -------------------------------------------------- -# IMAP_PASSWORD should be an app-specific password, not the account password. +# EMAIL_BACKEND selects the mail source: "graph" (Microsoft Graph API, OAuth) +# or "imap" (fallback; Microsoft has retired IMAP basic auth for outlook.com, +# so imap+app-password only works with non-Microsoft providers like Gmail). +# For "graph": register an Entra "app registration" for a personal Microsoft +# account at azure.microsoft.com > Microsoft Entra ID > App registrations +# (default tenant = "consumers"); add a delegated Mail.Read permission with +# admin/user consent, and create a client secret. Redirect URI type "Web", +# value must live behind the site's real HTTPS origin, e.g. +# https:///email/callback (callback route already exists in the +# backend). Backend code exchanges a code there. TenantID must be "consumers" +# for a personal outlook.com account. +# The first sync prints an authorisation URL into the container log; visit it, +# consent, and the refresh token is persisted to backend/token/msgraph_token.json. +# OAuth flow reference: https://learn.microsoft.com/en-us/graph/auth-v2-user EMAIL_BACKEND= +MSGRAPH_CLIENT_ID= +MSGRAPH_CLIENT_SECRET= +MSGRAPH_TENANT_ID=consumers +MSGRAPH_REDIRECT_URI= +# IMAP_PASSWORD should be an app-specific password, not the account password. +# Only read when EMAIL_BACKEND=imap. IMAP_HOST= IMAP_PORT=993 IMAP_EMAIL= diff --git a/backend/graph/bookmark.resolvers.go b/backend/graph/bookmark.resolvers.go index 5ada1a3..5d41182 100644 --- a/backend/graph/bookmark.resolvers.go +++ b/backend/graph/bookmark.resolvers.go @@ -51,7 +51,7 @@ func (r *mutationResolver) DeleteBookmark(ctx context.Context, id int) (*models. // Bookmarks is the resolver for the bookmarks field. func (r *queryResolver) Bookmarks(ctx context.Context) ([]*models.Bookmark, error) { var bookmarks []models.Bookmark - if err := r.Store.DB.Order("category ASC, created_at ASC").Find(&bookmarks).Error; err != nil { + if err := r.Store.DB.Order("category ASC, created_at DESC").Find(&bookmarks).Error; err != nil { return nil, err } return ptrs(bookmarks), nil