

If you can use workload identity federation, you probably should (see the next section). As of April 2021, an alternative exists – workload identity federation – which is available to applications running on specific non-Google Cloud platforms, such as AWS. But you probably still want to store it in an opaque way, so that someone else cannot easily “borrow” it and present an OAuth consent screen that impersonates your package.įor a long time, the recommended way to make authorized requests to an API in a non-interactive context was to use a service account token.
HOW TO GET AN APP TOKEN GOOGLE PASSWORD
It is not a secret in the same sense as a password or token.

Note that three-legged OAuth always requires the involvement of a user, so the word “secret” here can be somewhat confusing.Package maintainers might want to build this app in as a fallback, possibly taking some measures to obfuscate the client ID and secret and limit its use to your package. In both cases, I suggest you devise a nickname for each OAuth credential and use it as the credential’s name in GCP Console and as the appname argument to httr::oauth_app() or gargle::oauth_app_from_json(). Provide the path to the downloaded JSON file.The client secret goes in the secret argument.The client ID goes in the key argument.Two ways to package this info for use with httr or gargle, both of which require an object of class httr::oauth_app: At any time, you can navigate to a particular client ID and click “Download JSON”.You can capture the client ID and secret via clipboard right away.Do Create credentials > OAuth client ID.The basic steps are described in the Prerequisites section for doing Google OAuth 2.0 for Mobile & Desktop Apps: This is called three-legged OAuth, where the 3 legs are the app or client, the user, and Google. A regular user will generally need to send an OAuth2 token, which is obtained under the auspices of an OAuth “app” or “client”. Most APIs are used to create and modify resources on behalf of the user and these requests must include the user’s token. Package maintainers might want to build an API key in as a fallback, possibly taking some measures to obfuscate the key and limit its use to your package.

In any case, I suggest you take the opportunity to edit the API key from the Credentials page and give it a nickname.You can capture the new API key via clipboard right away or close this pop-up and copy it later from the Credentials page.From the Developers Console, in the target GCP Project, go to APIs & Services > Credentials.Some APIs aren’t really usable without a token, in which case an API key may not be relevant and you can ignore this section.

When using the package in a non-interactive or indirect fashion (e.g. a scheduled job on a remote server or via Shiny), it is wonderful to NOT have to manage a token, if the work can be done with an API key instead. If this is possible, it’s a good idea to expose this workflow in a wrapper package, because then your users can decide to go into a “de-authed” mode. Some APIs accept requests to read public resources, in which case the request can be sent with an API key in lieu of a token. This article is for people who have a specific reason to be more proactive about auth. Note that most users of gargle-using packages do not need to read this and can just enjoy the automatic token flow.
HOW TO GET AN APP TOKEN GOOGLE HOW TO
Here we describe how to obtain different types of credentials that can be important when working with a Google API: How to get your own API credentials How to get your own API credentials
