AuthState-class | R Documentation |
An AuthState
object manages an authorization state, typically on behalf of
a wrapper package that makes requests to a Google API.
The vignette("gargle-auth-in-client-package)
describes a design for wrapper
packages that relies on an AuthState
object. This state can then be
incorporated into the package's requests for tokens and can control the
inclusion of tokens in requests to the target API.
api_key
is the simplest way to associate a request with a specific
Google Cloud Platform project.
A few calls to certain APIs, e.g. reading a public Sheet, can succeed
with an API key, but this is the exception.
client
is an OAuth client ID (and secret) associated with a specific
Google Cloud Platform project.
This is used in the OAuth flow, in which an authenticated user authorizes
the client to access or manipulate data on their behalf.
auth_active
reflects whether outgoing requests will be authorized by an
authenticated user or are unauthorized requests for public resources.
These two states correspond to sending a request with a token versus an
API key, respectively.
cred
is where the current token is cached within a session, once one
has been fetched. It is generally assumed to be an instance of
httr::TokenServiceAccount
or
httr::Token2.0
(or a subclass thereof), probably
obtained via token_fetch()
(or one of its constituent credential
fetching functions).
An AuthState
should be created through the constructor function
init_AuthState()
, which has more details on the arguments.
new()
Create a new AuthState
AuthState$new( package = NA_character_, client = NULL, api_key = NULL, auth_active = TRUE, cred = NULL, app = deprecated() )
For more details on the parameters, see init_AuthState()
format()
Format an AuthState
AuthState$format(...)
...
Not used.
set_client()
Set the OAuth client
AuthState$set_client(client)
client
An OAuth client.
set_app()
Deprecated method to set the OAuth client
AuthState$set_app(app)
set_api_key()
Set the API key
AuthState$set_api_key(value)
value
An API key.
set_auth_active()
Set whether auth is (in)active
AuthState$set_auth_active(value)
value
Logical, indicating whether to send requests authorized with user credentials.
set_cred()
Set credentials
AuthState$set_cred(cred)
cred
User credentials.
clear_cred()
Clear credentials
AuthState$clear_cred()
get_cred()
Get credentials
AuthState$get_cred()
has_cred()
Report if we have credentials
AuthState$has_cred()
clone()
The objects of this class are cloneable with this method.
AuthState$clone(deep = FALSE)
deep
Whether to make a deep clone.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.