Skip to contents

Authorize rgoogleads to view and manage your Google Ads Account. This function is a wrapper around gargle::token_fetch().

By default, you are directed to a web browser, asked to sign in to your Google account, and to grant rgoogleads permission to operate on your behalf with Google Ads. By default, with your permission, these user credentials are cached in a folder below your home directory, from where they can be automatically refreshed, as necessary. Storage at the user level means the same token can be used across multiple projects and tokens are less likely to be synced to the cloud by accident.

If you are interacting with R within a browser (applies to RStudio Server, RStudio Workbench, and RStudio Cloud), you need a variant of this flow, known as out-of-band auth ("oob"). If this does not happen automatically, you can request it yourself with use_oob = TRUE or, more persistently, by setting an option via options(gargle_oob_default = TRUE).


  email = gargle::gargle_oauth_email(),
  path = NULL,
  cache = gargle::gargle_oauth_cache(),
  use_oob = gargle::gargle_oob_default(),
  developer_token = getOption("gads.developer.token"),
  token = NULL



Optional. Allows user to target a specific Google identity.


Path to JSON file with identifying the service account


Specifies the OAuth token cache.


Whether to prefer "out of band" authentication.


Your Google Ads Developer Token.


A token with class Token2.0 or an object of




Most users, most of the time, do not need to call gads_auth() explicitly -- it is triggered by the first action that requires authorization. Even when called, the default arguments often suffice. However, when necessary, this function allows the user to explicitly:

  • Declare which Google identity to use, via an email address. If there are multiple cached tokens, this can clarify which one to use. It can also force rgoogleads to switch from one identity to another. If there's no cached token for the email, this triggers a return to the browser to choose the identity and give consent. You can specify just the domain by using a glob pattern. This means that a script containing email = "*" can be run without further tweaks on the machine of either or

  • Use a service account token or workload identity federation.

  • Bring their own Token2.0.

  • Specify non-default behavior re: token caching and out-of-bound authentication.

  • Customize scopes.

For details on the many ways to find a token, see gargle::token_fetch(). For deeper control over auth, use gads_auth_configure() to bring your own OAuth app or API key. Read more about gargle options, see gargle::gargle_options.

See also

Other auth functions: gads_auth_configure(), gads_deauth()


if (FALSE) {
## load/refresh existing credentials, if available
## otherwise, go to browser for authentication and authorization

## force use of a token associated with a specific email
gads_auth(email = "")

## force a menu where you can choose from existing tokens or
## choose to get a new one
gads_auth(email = NA)

## -----------------------
## use own developer token
    email = "",
    developer_token = "your developer token"

## -----------------------
## use own OAuth client app
    path = "path/to/your/oauth_client.json"

gads_auth(email = "")