Skip to content

See the article Set up an OAuth client for instructions on how to get an OAuth client. Then you can use gm_auth_configure() to register your client for use with gmailr. gm_oauth_client() retrieves the currently configured OAuth client.


  client = NULL,
  path = gm_default_oauth_client(),
  key = deprecated(),
  secret = deprecated(),
  appname = deprecated(),
  app = deprecated()




A Google OAuth client, presumably constructed via gargle::gargle_oauth_client_from_json(). Note, however, that it is preferred to specify the client with JSON, using the path argument.


JSON downloaded from Google Cloud Console, containing a client id and secret, in one of the forms supported for the txt argument of jsonlite::fromJSON() (typically, a file path or JSON string).

key, secret, appname, app

[Deprecated] Use the path (strongly recommended) or client argument instead.


  • gm_auth_configure(): An object of R6 class gargle::AuthState, invisibly.

  • gm_oauth_client(): the current user-configured OAuth client.

See also

gm_default_oauth_client() to learn how you can make your OAuth client easy for gmailr to discover.

Other auth functions: gm_auth(), gm_deauth(), gm_scopes(), gmailr-configuration


if (FALSE) { # rlang::is_interactive()
# if your OAuth client can be auto-discovered (see ?gm_default_oauth_client),
# you don't need to provide anything!
# see and store the current user-configured OAuth client
(original_client <- gm_oauth_client())

# the preferred way to configure your own client is via a JSON file
# downloaded from Google Developers Console
# this example JSON is indicative, but fake
path_to_json <- system.file(
  "extdata", "",
  package = "gargle"
gm_auth_configure(path = path_to_json)

# confirm that a (fake) OAuth client is now configured
#> <gargle_oauth_client>
#> name: a_project_d1c5a8066d2cbe48e8d94514dd286163
#> id:
#> secret: <REDACTED>
#> type: installed
#> redirect_uris: http://localhost

# restore original auth config
gm_auth_configure(client = original_client)