Gmail and Google Calendar
Objective: connect your Gmail or Google Calendar to Yew.
Done when: the integration shows ✓ Active in My Integrations and your email or events show up in search.
Why This Needs Setup
Google only lets an app read your Gmail or calendar after you sign in and approve it, and the app has to be registered with Google. Yew doesn't ship a shared registration. Each install uses its own, which you create in a Google Cloud project. It's free, and it means your data goes straight from Google to your server.
You do this once. The same Google client works for both Gmail and Google Calendar.
Before You Start
Decide the address of your backend, because Google needs it now and only accepts an https address or localhost:
- Using Yew only on the machine it runs on: the default
http://localhost:8443works. - Using Yew from other devices: put the backend behind HTTPS first, and set
BACKEND_URLandOAUTH_REDIRECT_BASE_URLindocker-compose.yamlto that address. A plain LAN address such ashttp://192.168.1.50:8443doesn't work. See Reaching Yew From Another Machine.
In the steps below, <BACKEND_URL> means that value. Yew builds the redirect address from OAUTH_REDIRECT_BASE_URL, so keep it the same as the backend's BACKEND_URL.
1. Create a Google Cloud Project
- Go to the Google Cloud console and sign in.
- Create a new project, such as "Yew Search".
- Open APIs & Services > Library and enable the Gmail API, the Google Calendar API, or both.
2. Set Up the Consent Screen
- Open Google Auth Platform (shown as OAuth consent screen in some menus) and click Get Started.
- Enter an app name, such as "Yew Search", and your email address.
- For Audience, choose External.
- Finish the setup.
- Under Audience > Test users, add the Google account whose email or calendar you want to index.
Leave the app in Testing. Publishing it would require a review by Google, which a personal install doesn't need.
3. Create the OAuth Client
-
Open Clients and click Create Client.
-
For Application type, choose Web application.
-
Under Authorized redirect URIs, add one line for each integration you'll use:
<BACKEND_URL>/v1/user-integration/oauth/gmail/callback
<BACKEND_URL>/v1/user-integration/oauth/google-calendar/callbackWith the default address that's
http://localhost:8443/v1/user-integration/oauth/gmail/callback. The address must matchOAUTH_REDIRECT_BASE_URLexactly, includinghttporhttpsand the port. -
Click Create, then copy the Client ID and Client Secret.
4. Configure the Integration in Yew
- In Yew, open Browse Integrations.
- Next to Gmail (or Google Calendar), click Configure Integration.
- Paste the Google OAuth Client ID and Google OAuth Client Secret, then click Save Configuration.
The secret is stored and never shown again. To change it later, click the pencil icon next to the integration and confirm with Yes - Reconfigure, then click Update Configuration. Reconfiguring replaces the saved client, and any connected account has to sign in again before it can sync.
5. Connect Your Account
- Click Add Integration next to Gmail.
- Optionally, enter a Name, then click Connect to Gmail. Google's sign-in opens in a new tab. Don't click the Add Integration button below it: that saves an integration without signing in to Google, which can't sync.
- Sign in with a test user from step 2.
- Google warns that it hasn't verified the app. That's expected for an app in Testing: click Continue.
- Approve the access Yew asks for.
Google sends you back to Yew, which opens the new integration's page and starts the first sync. Google Calendar works the same way, with Connect to Google Calendar.
Troubleshooting
Google shows "redirect_uri_mismatch". The redirect URI in your Google client doesn't match OAUTH_REDIRECT_BASE_URL in docker-compose.yaml. Compare the two character by character, including the protocol, the port and any trailing slash.
Google shows "Access blocked" or "access_denied". The account you signed in with isn't a test user. Add it under Audience > Test users.
The integration shows ⚠ Needs re-auth after a week. Google expires sign-ins for apps in Testing after 7 days. Open the integration in My Integrations and click Re-authenticate.
Yew shows "OAuth session expired. Please try again." The sign-in took more than 5 minutes. Start again from Add Integration.
Still stuck? Ask at answers.yewsearch.com. It searches these docs with Yew Search and writes an answer with links to the pages it used.