-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
handle server to server auth #54
Comments
I'm aiming to use the googleAnalyticsR package as the back-end API client for ganalytics. This will offer added benefits from that package including service account authentication. |
@MarkEdmondson1234 and @zippeurfou , now that |
The token created is the same as via httr, just via the |
The dev branch now has support for service account authentication. Here is a link to the commit with the necessary changes: 4fb9738 I'll merge this into the master branch at some later point as I may be making some further improvements around this. Here's a demo, if you would like to test it out, of using a service account to access the Real Time reporting API: # It is recommended that you restart your R session before continuing with
# the following.
# Install the dev version of ganalytics from GitHub - be patient as this may
# take around 5 minutes to complete.
install.packages("remotes")
remotes::install_github("jdeboer/ganalytics@dev")
# Load ganalytics
library(ganalytics)
# Set credentials - remember to change the secrets filepath to your own service
# account secrets json file. You should obtain this file from the API credentials
# manager in Google Cloud Conosle.
creds <- GoogleApiCreds(secrets = "~/api-service-account-secrets.json")
# Define your query - remember to set the view ID to your Google Analytics view
# that you want to query.
my_rt_query <- RtQuery(
view = 117987738,
metrics = "activeUsers",
dimensions = "userType"
)
# As the GA Real Time API is still in limited beta, you need to sign up for
# access via this form before you execute your query:
# https://docs.google.com/forms/d/1qfRFysCikpgCMGqgF3yXdUyQW4xAlLyjKuOoOEFN2Uw/viewform
# Execute the query with the supplied credentials.
GetGaData(my_rt_query, creds = creds) |
Using google JWT.
i.e. in node js
googleapis
it works like that:Then you can access your data as follow:
Therefore, you only need an email and private key and it does the rest for you (no need to auth via a webpage).
The text was updated successfully, but these errors were encountered: