Since Google is always changing how you configure things, I figured I’d post current instructions for creating your own Google Cloud OAuth client and a custom google.provider
that uses it.
Background
Since KDE is on Google’s shitlist, the keys in Plasma’s built-in google.provider
don’t grant you access to Google Drive. To work around this, you can create your own OAuth Client in Google Cloud console and a custom version of google.provider
that uses it.
Caveats
-
It seems that Plasma doesn’t handle token refresh correctly, so this will stop working after a week or so. When that happens, just remove the account from Online Accounts and re-add it. As long as you give it the same name it had before, any existing
gdrive:
paths should continue to work. -
I don’t know whether access to other Google APIs work with this setup. I haven’t tested sharing videos to YouTube, and as far as I can tell, Plasma doesn’t do anything with the contacts, calendars, and tasks APIs, despite asking for access to them. (Akonadi seems to do its own thing.)
Instructions
Tested on 2025-05-23 with a normal Google account.
Create a project
-
Open the “object picker” (at the top, next to the Google Cloud logo) and click “New Project” in the upper right of the dialog box that appears.
-
Name your project whatever you like. I used
kio-gdrive
. The default location (“No organization”) should be fine. -
If this is your first project, GCloud console should switch you to it immediately. If you already had another project selected, you’ll have to switch manually by opening the object picker again and clicking on your new project.
Enable APIs
Once you’re “working in” your new project, use the search box at the top of the screen to search for “API Library”. You’re going to turn on a few APIs that KDE wants to use. I’m just going to list the API names. The easiest way to find them is probably with the search box — no not that search box — the one that says “Search for APIs & Services”. For each one, click on it and then click “Enable”.
- Contacts API
- Google Calendar API
- Google Drive API
- Google Tasks API
- YouTube Data API v3
Each time you enable an API, it’ll take you out of the API Library, so you’ll have to click back into it by selecting “Library” from the sidebar. Rinse and repeat!
Set up Auth Platform
-
Once you’ve got all the relevant APIs enabled, use the search box to search for “Google Auth Platform”. You should see the message “Google Auth Platform not configured yet” — click the “Get started” button below that message.
-
Now we’re going to pretend that we’re deploying an “App” that will be “Published”, have an “Audience”, require “Support” for “Users”, and other such foolishness. You can pretty much put in whatever you like here. Here’s what I did:
- App name: KDE Online Accounts
- User support email: (the email address that google has on file for me)
- Audience: External
- Contact Information: (just that same email again)
- Finish: check the “I agree to…” checkbox
-
Click “Create”. This takes you back to the “Google Auth Platform” overview.
-
Select “Audience” from the sidebar. Under “Test users”, click “Add users” and add the login emails of any Google accounts you want to log into from Plasma.
-
Select “Clients” from the sidebar. At the top, click “Create client”. Select “Desktop app”
for the application type and give it a name. I used “KDE Online Accounts” again, but you can pick anything you like. Click “Create”. -
In the “OAuth client created” dialog, take note of your Client ID and Client secret values. You’ll need to put these in your custom
google.provider
file. -
Select “Data Access” from the sidebar. Click “Add or remove scopes”. In the dialog/sidebar thingy, scroll down to “Manually add scopes”, paste in the following lines, and click “Add to table”:
https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile https://www.google.com/m8/feeds/ https://www.googleapis.com/auth/calendar https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/tasks https://www.googleapis.com/auth/youtube.upload
-
Click “Update”, then click “Save”.
Create a custom google.provider
-
Copy
/usr/share/accounts/providers/kde/google.provider
to~/.local/share/accounts/providers/google.provider
. Create directories as needed. Open your copy for editing. -
Add the Google Drive API’s scope —
https://www.googleapis.com/auth/drive
— to the list in the<setting type="as" name="Scope">
element. Make sure you quote the URL and put a comma after it. (This is a JSON list, I guess.) -
Change value of the
<setting name="ClientId">
element to the OAuth 2.0 Client ID you saved earlier. -
Change the value of the
<setting name="ClientSecret">
element to the OAuth 2.0 Client secret you saved earlier. -
If you like, change the value of the
<description>
element to mention “files” or whatever. (This also helps you tell if Plasma is using your new provider.) -
If you have Plasma’s System Settings open, close and reopen it. Then add a Google Account to Online Accounts in the normal way.
Anyway…
I hope folks find this helpful. Let me know if you run into issues or if Google changes where all the settings are yet again!