Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

init_AuthState

Create an AuthState


Description

Constructor function for objects of class AuthState.

Usage

init_AuthState(
  package = NA_character_,
  app = NULL,
  api_key = NULL,
  auth_active = TRUE,
  cred = NULL
)

Arguments

package

Package name, an optional string. The associated package will generally by implied by the namespace within which the AuthState is defined. But it's possible to record the package name explicitly and seems like a good practice.

app

Optional. An OAuth consumer application, as produced by httr::oauth_app().

api_key

Optional. API key (a string). Some APIs accept unauthorized, "token-free" requests for public resources, but only if the request includes an API key.

auth_active

Logical. TRUE means requests should include a token (and probably not an API key). FALSE means requests should include an API key (and probably not a token).

cred

Credentials. Typically populated indirectly via token_fetch().

Value

An object of class AuthState.

Examples

my_app <- httr::oauth_app(
  appname = "my_package",
  key = "keykeykeykeykeykey",
  secret = "secretsecretsecret"
)

init_AuthState(
  package = "my_package",
  app = my_app,
  api_key = "api_key_api_key_api_key",
)

gargle

Utilities for Working with Google APIs

v1.1.0
MIT + file LICENSE
Authors
Jennifer Bryan [aut, cre] (<https://orcid.org/0000-0002-6983-2759>), Craig Citro [aut], Hadley Wickham [aut] (<https://orcid.org/0000-0003-4757-117X>), Google Inc [cph], RStudio [cph, fnd]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.