Problem
You connect a Google account through your own Google app, and Google shows Error 400: redirect_uri_mismatch or "Access blocked: This app's request is invalid". Or the plugin says: The redirect URI in your Google client doesn't match.
Cause
When you sign in, Google sends you back to an address that you entered in your Google client under Authorized redirect URIs. That address must match the one the plugin uses exactly: https or http, www or not, the path and the query, character for character. Common reasons:
- The address wasn't added to the client, or with a small difference.
- You just added it. Google can take a few minutes, sometimes longer, to apply a change.
- The address of your site changed: a new domain, https, www added or removed, or a staging copy.
- The app was switched between your site's own address and the sign-in page of WP Cloud Plugins, and the client only has the other address.
Which address does my app use?
Each Google app in the plugin uses one of two addresses:
-
Your site's own address:
https://example.com/wp-admin/admin-post.php?action=useyourdrive_oauth(with your own domain). Google sends you straight back to your site. -
The sign-in page of WP Cloud Plugins:
https://www.wpcloudplugins.com/use-your-drive/index.php. Used when Google can't accept your site's own address, for example on a site without https or on a local domain. External apps then also needwpcloudplugins.comunder Branding → Authorized domains.
To see the address of an app: in WordPress, go to Google Drive → Settings, open the Dashboard tab and click the info icon (Details) next to the app under Your Google apps. The details show the Redirect URI with a copy button, and let you switch to the other address.
Solution
- Copy the redirect URI from the details of the app in the plugin (see above), or from the setup.
- Open Google Auth Platform → Clients, select the project of your app at the top and open the client.
- Under Authorized redirect URIs, click Add URI, paste the address and click Save. You can keep the other addresses: a client can have several, for example for your live site and a staging copy.
- Wait a few minutes. Then click I added it in the plugin, if it shows that button, and connect the account again.
Does your app use your site's own address, and does the error stay? Your site may not be reachable for Google's redirect, for example because a security plugin hides wp-admin. Then click Use the sign-in page of WP Cloud Plugins instead in the details of the app, add https://www.wpcloudplugins.com/use-your-drive/index.php to the client, and (for an External app) add wpcloudplugins.com under Branding → Authorized domains.
After a domain change
When the address of your site changes, the plugin shows it on the app: The address of your site has changed … with the new redirect URI. Add that address to your client and click I added it, or click Use the sign-in page of WP Cloud Plugins on this site. Is the main domain new as well, and is the app External? Then also add it under Branding → Authorized domains. Accounts that are connected keep working in the meantime: the redirect URI is only needed to connect an account.