gar_gce_auth_default {googleAuthR} | R Documentation |
Authenticate via gcloud's application-default login
Description
This allows you to take gcloud's application-default login token and turns it into one that can be used by R
Usage
gar_gce_auth_default(
scopes = getOption("googleAuthR.scopes.selected",
"https://www.googleapis.com/auth/cloud-platform")
)
Arguments
scopes |
The scope you created the access_token with |
Details
When authenticating on Google Cloud Platform services, if you are using services that take the cloud scopes you can use gar_gce_auth to generate authentication.
However, for other services that require a user login (such as Google Analytics API), you need a method of authentication where you can use your own email login. You have two options - create a token offline and upload it to the instance, or gcloud
allows you to generate your own token online via gcloud auth application-default login && gcloud auth application-default print-access-token
This function will then take the returned access token and put it within R so it can be used as normal with googleAuthR
functions.
See Also
Examples
## Not run:
## in the terminal, issue this gcloud command specifying the scopes to authenticate with
gcloud auth application-default login \
--scopes=https://www.googleapis.com/auth/analytics.readonly
## access the URL, login and create a verification code, paste in console.
## view then copy-paste the access token, to be passed into the R function
gcloud auth application-default print-access-token
## In R:
gar_gce_auth_default(<token-copy-pasted>,
scopes = 'https://www.googleapis.com/auth/analytics.readonly',
cache_file = 'my_ga.auth')
# use token to authenticate as you would normally with library
## End(Not run)