Authorizing a plugin to call Google Analytics v4 API on wp_cron

Answering my own question:

I reviewed another well-known plugin, Google Analytics, which provides both approaches to the user: The user can either:

  1. Use the plugin’s client id and secret key to request an authorization code with offline access. The user pastes the code into a text field and the plugin proceeds to request an access token.

  2. Go to the developer console, create a new project, copy-paste the client id and secret from the developer console into the plugin, then proceed with authorization.

I ended up implementing the first approach only. It seems the most appropriate for novice users.

I am still unsure as to whether publishing the client secret is an issue, but what I know is that at least two major WordPress plugins do it already…