Experiment, Fail, Learn, Repeat

Life is too exciting to just keep still!

RGoogleslides - using your own account client id and secret

NOTE: BEFORE READING THIS - ALL SCREENSHOTS BELOW ARE TAKEN SOMETIME IN OCTOBER 2021. THE UI MAY CHANGE IN THE FUTURE - USE THIS AS A ROUGH GUIDE AND NOT AS ABSOLUTE TRUTH

There is a very important function in RGoogleslides - without which, the package might as well wouldn’t function:

authorize()

The following function does the step of getting the user to authenticate to the relevant Google services which in this case is Google Drive and Google Slides. Google Drive API access is to allow the package to create Google Slides on your behalf while the Google Slides API access is to allow us to programmatically manipulate the Google Slides

The function comes with its own default secret id and secret key - but of course, this SHOULD NOT BE USED IN PRODUCTION. Let me repeat this point: DO NOT JUST USE THIS AND USE IT IN PRODUCTION - Don’t just implicitly trust the secret ids, key access being used here. Anything can happen - e.g. owner’s GCP account gets hacked, owner of the project may accidentally delete the secret ids and secret keys, or too many users use the key and it hit some sort of quota etc. Let’s just say, it may be fine in the short while - but anything can happen in the long run.

Luckily, the function optionally accepts a client secret and client key generated by the user’s own GCP account

Showcase of authorize function in the Rgoogleslides package

You can create the key in a GCP account in the following way. You might first need to check that Google Drive and Google Slides API is on. You can see if the following set of images can help guide you that way.

Image of how to access api library in Google Cloud Console Showcase of search for APIs in Google Cloud Console

You will need to ensure the Drive and Slides API are turned on

Google Drive API permission page

In order to create and get the client secret and client key for the package. You can try following the steps

How to access the credentials page from sidebar in Google Cloud Console Click on Create Credentials to create the credentials need for app Choosing to create oauth client from credentials page in Google Cloud Console

We need to pick the “Desktop App” type

Clicking on the desktop app type for oauth client credentails in Google Cloud Console

That would immediately generate the client secret and client key.

You can immediately use similar to the code snippet below:

authorize("XXXXXX.apps.googleusercontent.com", "XXXXX")
slideID = create_slides("TEXT")

The following code snippet should work after that - there could be some account differences but it should be resolvable