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

There will be a link towards the top of the page that will lead to the start of the authorization process.

An image of the connection dialog box

Choose the Google account to use.

An image of the app authorization page

Now, there will be a notice from google mentioning that WP Overnight (us) wants access to your Google Account. This is because we shall upload to your google drive account.

If you previously connected your account, you will notice a section mentioning this:

`WP Overnight already has some access`

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.

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.

  1. Select “Delete refresh token on unlinking“.

2. Click “Unlink Google Drive account“.

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‘.
  • Click on the ‘options‘ button on the right-side of the app.
  • Delete the 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 extensions license caching.

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.