feat(mobile): OAuth2 mobile endpoint and Mail Settings field (#485)#496
Merged
krantheman merged 4 commits intoJun 1, 2026
Merged
Conversation
…ppe#485) - Add mail/api/mobile.py with two endpoints: - get_client_id (allow_guest): returns OAuth client_id, app_name, logo, and sitename for the mobile app's site-validation step - create_oauth_client (System Manager): auto-creates or updates the OAuth Client doctype and stores the ID in Mail Settings - Add mobile_oauth_client field to Mail Settings under a new Mobile tab - Redirect URI registered as com.frappe.mail://oauth (matches iOS Info.plist and Android AndroidManifest.xml stubs from frappe#484) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Reflow two get_single_value expressions to the project's 110-char line length and wrap the long frappe.throw call, fixing the ruff-format pre-commit hook in CI. No behavior change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Adds an Actions button that calls mail.api.mobile.create_oauth_client and reloads the form, so admins can provision the mobile OAuth client from the UI instead of calling the endpoint by hand (the field description already pointed at this button). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The endpoint must be allow_guest=True (the mobile app fetches the public OAuth client_id before login) and returns only non-sensitive public config, so suppress the guest-whitelisted-method semgrep rule with a justification. Same pattern as Raven's equivalent endpoint. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
mail/api/mobile.pywith two endpoints:get_client_id(allow_guest=True) — called by the mobile app before login to validate the site and fetch the OAuth client ID, app name, logo, and sitename. Returns only non-sensitive public config; reviewed and marked# nosemgrepfor theguest-whitelisted-methodrule (same pattern as Raven's equivalent endpoint).create_oauth_client(requires Mail Settings write permission) — auto-creates or updates a FrappeOAuth Clientdoc and stores its ID in Mail Settings, so admins don't need to configure it manuallymobile_oauth_client(Link → OAuth Client) field to Mail Settings under a new Mobile tabcreate_oauth_clientand reloads the formcom.frappe.mail://oauth— matches the iOSInfo.plistand AndroidAndroidManifest.xmlstubs added in Mobile: NativeScript + Vue 3 project scaffolding #484Modeled on Raven's mobile-login approach (guest
get_client_iddiscovery + admincreate_oauth_client, Authorization Code flow against Frappe's OAuth provider). Note: mail users are identified byis_jmap_configured(aUser Settingscheck), not a role, so the OAuth client is not role-gated — the mail APIs already enforceis_jmap_configured.Admin setup flow
client_idfromget_client_idTest plan
Verified on a dev site (
bench migrate+ console/HTTP):get_client_idraisesDoesNotExistErrorwhen no OAuth client is configuredcreate_oauth_client,get_client_idreturnsclient_id,app_name,logo,sitename(also confirmed over HTTP as guest — no auth)create_oauth_clientraisesPermissionErrorfor users without Mail Settings write permissionbench migratecom.frappe.mail://oauth, Authorization Code / Code,scopes = all openid)Closes #485
🤖 Generated with Claude Code