scr_auth

0th

Percentile

Do OAuth2 authentication

Do OAuth2 authentication

Usage
scr_auth(token = NULL, new_user = FALSE, no_auto = FALSE)
Arguments
token

Where you want to save the auth file, or an existing token or file location of a token to authenticate with

new_user

If TRUE, reauthenticate via Google login screen

no_auto

Skip auto authentication

Details

Run this function first time to authenticate with Google in your browser.

After initial authentication, a sc.oauth will be saved to your working directory, where your authentication details are kept. Keep this file safe.

If you want to reauthenticate, delete this file from your directory or run scr_auth(new_user = TRUE)

Multiple accounts

You can authenticate with a new auth file for each account. Supply argument token with the name of the cache file you want to use e.g. scr_auth(token = "one.httr-oauth") for one account, scr_auth(token = "another.httr-oauth") for a different account.

Auto-authentication

You can choose to auto-authenticate by moving your sc.httr-oauth or by creating a Google OAuth service account JSON file.

Specify an environment variable in R via a .Renviron file or using Sys.setenv which point to the file location of your chosen authentication file. See Startup

Once you have set the environment variable SC_AUTH_FILE to a valid file location, the function will look there for authentication details upon loading the library meaning you will not need to call scr_auth() yourself as you would normally.

An example .Renviron file is below:

SC_AUTH_FILE = "/Users/bob/auth/sc.oauth"

SC_AUTH_FILE can be either a auth file for a token generated by gar_auth or service account JSON ending with file extension .json

Your own Google Project

Be default the Google Project used is shared by all users, this is usually sufficient, but you could choose to create your own Google Project and turn on the Webmaster APIs.

You can then download your own client JSON, and set by placing in the GAR_CLIENT_JSON environment argument. See gar_set_client for details.

Service accounts

If you use the service account JSON, you will need to add the service account email to your Search Console users to see data e.g. xxxx@yyyyyy.iam.gserviceaccount.com

See Also

gar_auth

Aliases
  • scr_auth
Documentation reproduced from package searchConsoleR, version 0.3.0, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.