Authorize gmailr to view and manage your Gmail projects. This function is a
By default, you are directed to a web browser, asked to sign in to your
Google account, and to grant gmailr permission to operate on your
behalf with Google Gmail. By default, these user credentials are cached in a
folder below your home directory,
~/.R/gargle/gargle-oauth, 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.
1 2 3 4 5
Optional. Allows user to target a specific Google identity. If
specified, this is used for token lookup, i.e. to determine if a suitable
token is already available in the cache. If no such token is found,
JSON identifying the service account, in one of the forms
supported for the
One or more gmail API scope to use, one of 'labels', 'send',
'readonly', 'compose', 'insert', 'modify', 'metadata', 'settings_basic',
'settings_sharing' or 'full' (default: 'full'). See
https://developers.google.com/gmail/api/auth/scopes for details on the
permissions for each scope. and
Specifies the OAuth token cache. Defaults to the option named
"gargle_oauth_cache", retrieved via
Whether to prefer "out of band" authentication. Defaults to
the option named "gargle_oob_default", retrieved via
A token with class Token2.0 or an object of
Most users, most of the time, do not need to call
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 gmailr 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.
Use a service account token.
Bring their own Token2.0.
Specify non-default behavior re: token caching and out-of-bound authentication.
For details on the many ways to find a token, see
gargle::token_fetch(). For deeper control over auth, use
gm_auth_configure() to bring your own OAuth app or API key.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
## Not run: ## load/refresh existing credentials, if available ## otherwise, go to browser for authentication and authorization gm_auth() ## force use of a token associated with a specific email gm_auth(email = "email@example.com") ## force a menu where you can choose from existing tokens or ## choose to get a new one gm_auth(email = NA) ## use a 'read only' scope, so it's impossible to change data gm_auth( scopes = "https://www.googleapis.com/auth/gmail.readonly" ) ## use a service account token gm_auth(path = "foofy-83ee9e7c9c48.json") ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.