OAuth app

googledrive helps you obtain a token to work with the Google Drive API from R primarily through the drive_auth() function. Under the hood, that process relies on an OAuth client and secret, a.k.a. an “OAuth app”.

If there is a problem with googledrive’s internal OAuth app or if you would prefer to use your own, you can configure this. Here we describe how.

Get an OAuth app

Follow the instructions in the gargle article How to get your own API credentials to get an OAuth client ID and secret.

Now register it with googledrive.

googledrive v0.1.3 and earlier

Method 1: Create an OAuth app directly, providing the client ID as key and client secret as secret.

Method 2: Create an OAuth app by providing the path to the JSON file downloaded from the Google Cloud Platform Console.

Development version of googledrive

Difference from earlier versions: drive_auth_config() is being soft-deprecated, in favor of drive_auth_configure().

Method 1: Create an OAuth app directly, providing the client ID as key and client secret as secret.

Method 2: Create an OAuth app by providing the path to the JSON file downloaded from the Google Cloud Platform Console.

Confirm success and carry on

You can see the currently configured OAuth app like so:

You should see your own app there now.

For the rest of this R session, when you get a new token with drive_auth(), your OAuth app is used.

API key

googledrive can make unauthorized calls to the Google Drive API, for example accessing a file available to “Anyone with a link”, by sending an API key, instead of a user token.

If there is a problem with googledrive’s internal API key or if you would prefer to provide your own, you can configure this. Here we describe how.

Get an API key

Follow the instructions in the gargle article How to get your own API credentials to get an API key. You probably want to use the same GCP project to create both your OAuth app (above) and your API key.

Now register it with googledrive.

googledrive v0.1.3 and earlier

drive_auth_config(api_key = "YOUR_API_KEY_GOES_HERE")

Development version of googledrive

Difference from earlier versions: drive_auth_config() is being soft-deprecated, in favor of drive_auth_configure().

drive_auth_configure(api_key = "YOUR_API_KEY_GOES_HERE")

Confirm success and carry on

You can see the currently configured API key like so:

You should see your own API key now.

For the rest of this R session, if you go into a de-authorized state via drive_deauth(), your API key will be sent with the request.