Skip to content

OAuth 2.0 authentication fails when trying to connect to Google Drive #277

Open

Description

@aitoolkithub

Hi,

I've been testing a couple of plugins I created that connect to Google Drive. One of them is just for getting information about storage space, the folder tree, and their respective sizes. The other creates backups directly to Google Drive. The problem is that when I try to connect them while in Desktop Mode, I get a Google 403 error. I have to switch to Classic Mode to connect, and then I can go back to Desktop Mode and use them. This problem occurs with both plugins. Here are screenshots of the issue with one of them.

Before attempting to make the connection in Desktop Mode:
Image

Here's the 403 Google error message in Desktop Mode:
Image

Now, trying to make the connection in Classic Mode:
Image

Then it takes me to the account selection screen:
Image

Getting the succesfully connected to Google Drive message in Classic Mode:
Image

Finally, switching to the Desktop Mode with the plugin connected and working:
Image

Best regards,
AI Toolkit Hub

Activity

  1. added
    factory
    and removed
    factory
    on Nov 9, 2026
  2. added
    factory
    on Nov 21, 2026
  3. epeicher commented on Nov 21, 2026

    @epeicher
    Collaborator

    Factory intake: NEEDS-INFO

    Summary

    • The report: connecting a plugin to Google Drive from inside a window ends on a Google 403, and only works after switching to classic admin.
    • The cause is known: Google's sign-in page refuses to load inside a frame, and every admin screen in the desktop is a frame.
    • Since this was reported, two of the ways a plugin can send the browser to Google have been handled. Three others still load Google inside the window.
    • Which one your plugins use decides whether there is anything left to fix and what the fix is, so there are three short questions before anything is built.

    Scope

    Nothing will be built yet. It waits on the answers below.

    Why

    A window is an iframe, and Google answers a framed sign-in request with a 403, so the flow can only work when the shell gets the browser out of the frame first. Today it does that in two cases. A plain link to another site opens in a new browser tab (the click interceptor in src/chromeless-bridge.js, the offsite branch). A PHP wp_redirect() to another site is handed to the shell, which closes the window, follows the redirect in the tab like classic admin does, and brings you back to the desktop when Google returns you to wp-admin (openstation_chromeless_hand_off_offsite_redirect() in includes/core/routing.php). Three cases are not handled and still land on the 403: a form whose action is the Google URL (the submit interceptor only rewrites wp-admin URLs), a redirect sent with a raw header( 'Location: ...' ) instead of wp_redirect(), and JavaScript that sets window.location. Each of those needs a different fix in code that runs inside every window, and I could not open the screenshots to tell which one applies, so I would rather ask than guess.

    If you need it working right now: switching the redirect to wp_redirect() is handled today, and the plugin also ships an OAuth helper that runs the sign-in in a popup (openstation_register_oauth_relay() with wp.os.startOAuth(), see docs/examples/oauth-relay.md).

    Questions

    1. Does this still happen on the current OpenStation release? (The plugin was called Desktop Mode when you reported it.)
    2. How does your Connect button send the browser to Google: (a) a plain link to accounts.google.com, (b) a form whose action is the Google URL, (c) PHP wp_redirect(), (d) PHP header( 'Location: ...' ), or (e) JavaScript setting window.location?
    3. Is either plugin public? A link to it, or the few lines that start the connection, would let us reproduce this.
  4. added
    factory:needs-info
    on Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    factoryfactory:needs-info

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions