// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie // SPDX-License-Identifier: MIT //! The OAuth scopes the Gmail API understands, written out so that a typo is //! a compile error rather than a consent screen that refuses. //! //! Google sorts these into three tiers and the tier decides what it costs to //! ship the application, not what it costs to write it. The **restricted** //! ones -- everything that can see the content of a message -- require a //! security assessment before an app using them may be published, so an app //! that only needs to know which messages exist and what they are labelled //! should ask for `labels` and `metadata` and stop there. //! //! Ask for the narrowest set that works. A refresh token is only as //! dangerous as the scopes attached to it. /// See and edit labels. Non-sensitive: it cannot see a message. pub const labels = "https://www.googleapis.com/auth/gmail.labels"; /// Send mail. Sensitive, and cannot read anything. pub const send = "https://www.googleapis.com/auth/gmail.send"; /// Headers and labels, but never a body. Restricted. /// /// This is the narrowest scope that can walk a mailbox and see who a message /// is from, and it is enforced rather than advisory: `getMessage` with /// `format = .full` or `.raw` is refused outright, and only /// `format = .metadata` works. pub const metadata = "https://www.googleapis.com/auth/gmail.metadata"; /// Read everything, change nothing. Restricted. pub const readonly = "https://www.googleapis.com/auth/gmail.readonly"; /// Read, label and send; cannot permanently delete. Restricted. pub const modify = "https://www.googleapis.com/auth/gmail.modify"; /// Create and send drafts. Restricted. pub const compose = "https://www.googleapis.com/auth/gmail.compose"; /// Insert messages into the mailbox without sending them. Restricted. pub const insert = "https://www.googleapis.com/auth/gmail.insert"; /// Read, write, send and permanently delete. Restricted, and the one to /// justify to yourself before asking for it. pub const full = "https://mail.google.com/"; /// See and change filters, forwarding, signatures and the like. Restricted. pub const settings_basic = "https://www.googleapis.com/auth/gmail.settings.basic"; /// Delegation, aliases and other settings that give away access. Restricted. pub const settings_sharing = "https://www.googleapis.com/auth/gmail.settings.sharing"; /// What a program that mirrors a mailbox to local storage needs: the message /// bodies, and the label list to render `labelIds` with. pub const mirror: []const []const u8 = &.{ readonly, labels }; const std = @import("std"); const testing = std.testing; test "the scopes are URLs and each is distinct" { const all = [_][]const u8{ labels, send, metadata, readonly, modify, compose, insert, full, settings_basic, settings_sharing, }; for (all, 0..) |a, i| { try testing.expect(std.mem.startsWith(u8, a, "https://")); for (all[i + 1 ..]) |b| try testing.expect(!std.mem.eql(u8, a, b)); } }