(Coming soon) – Authorizing Google Drive

As PDF Invoices & Packing Slips for WooCommerce – Professional is installed and activated, the new Cloud Storage tab is added at WooCommerce > PDF Invoices > Cloud Storage. In order to proceed:

  1. Cloud storage has to be enabled.
  2. Google Drive has to be selected as the Cloud service.
  3. The settings need to be saved.

Get an access code #

Path: WooCommerce > PDF Invoices > Cloud Storage

This requires getting an access code. A dialog box towards the top of the page will contain the link to start the process.

Start the code acquisition process by clicking the permalink that reads ‘this link‘ to authorize your account. Clicking this will now successfully lead to the next authorization step.

An image of the connection dialog box

The next step: obtaining a new Google Drive access token from the WPO Tokens app. This will lead to a new screen where permission shall be requested.

An image of the app authorization page

After selecting a Google account and accepting authorization to get a token, click the ‘Finish authorization‘ button.

An image of there…. google authorization token

On authorization success, there should be:

  • A success notice at the top of the page that reads: “Google Drive connection established“.
  • A section displaying basic Google Drive connection credentials.
  • A button titled ‘Unlink Google Drive account‘ in the connection dialog box.
An image showing authorization success

Disconnect Google Drive #

The first step is to click the ‘Unlink Google Drive account‘ at WooCommerce > PDF Invoices > Cloud Storage.

This is very important because the Google account authorization token successfully reconnects with your account, yet the refresh token causes a mismatch.

An image showing the need to unlink google drive

Next:

  • Go to https://drive.google.com on your device where your connect google account is logged-in.:
  • Click on the Drive settings button (top-right of the page).
  • Click on ‘Settings‘.
An image of the google drive settings menu

Once at the Google Drive settings:

  • Click on ‘Manage Apps‘.
  • Scroll down till you find ‘WP Overnight – Cloud Storage
  • Click on the ‘options‘ button on the right-side of the app.
  • Delete the app.
An image of the wpo google-drive app
An image of the wpo google-drive app

After deleting the app, return to the authorization screen at:
WooCommerce > PDF Invoices > Cloud Storage.

Troubleshooting #

Google drive refresh token issue #

There are times, when trying to authorize your Google Drive connection fails, with the following notice:

“Your access token has been retrieved, but the refresh token or the token expiration details are missing. To fix this, please revoke the current permissions for this app following the steps outlined in our revoke and reauthorize documentation. After revoking, reauthorize the application to ensure you receive all necessary tokens for full functionality.”

An image showing unsuccessful authorization

To fix this, disconnect your Google Drive account following the steps outlined in this same article.

CSRF Token issue #

You may get an error that appears as a blank screen with the following text:

“CSRF token required”

An image showing an error screen

This happens if the connection was interrupted, like refreshing a page while the connection was still being established.
In order to resolve this, you must clear your browser’s cookies. This process may be different per web browser.

How to clear browser cache: #

Activate professional extension license #

If the Professional extension license has not been activated on the WordPress installation, there will be a notice that must be resolved, in order to proceed.

“Activate your Professional extension license!”

“To keep Google Drive API limits under control, you are required to activate your Professional extension license to use this service. See how to activate your license here or clear the cache here.”

An image showing a google-drive notice

Clear license cache #

Path: WooCommerce > PDF Invoices > Advanced > Tools > Clear Professional extension license cache.

If the activation notice does not appear to change when it should, it could be an indication that the license cache needs to be cleared.

An image showing clearing the cache

The correct activation notice should then appear in the Cloud storage tab, which reads:

Authorize Google Drive service!
Visit Google Drive via this link to authorize your account.

Advanced Notes #

During the authorization phase, we capture and store:

  • access_token
  • refresh_token
  • the expires_in timestamp.

The expiration timestamp helps in determining when to request a new access token using the refresh token. The refresh token remains constant, so if it is missing or invalid, the user must:

  • Unlink the Google Drive account.
  • Remove our ‘WP Overnight – Cloud Storage‘ application from the Google Drive service account.