'Access Google's Campaign Manager 360 Reporting API with R

I am trying to access campaign manager 360 Reporting API with using the httr package in R. This is the code I have run so far to test the connection and I keep getting a 403 error code. I already created the API credentials on Google Console and Campaign Manager API is activated on the Google Console App. A lot of the preset packages in R for this seem to be linking back to old urls that are no longer valid.

I am trying to pull campaign metrics data for the campaigns running through CM360.

This is the code I have so far. Any advice is truly appreciated!

library(httr)
library(jsonlite)

dcm_user_id <- "xxxxxxx"
report_id <- "xxxxxxxxx"
dcm_key <- "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
secret <- "xxxxxxxxxxxxxxxxxxx"

dcm_app <- oauth_app("google", key = dcm_key, secret = secret)
google_token <- oauth2.0_token(oauth_endpoints("google"), dcm_app, scope = "https://www.googleapis.com/auth/dfareporting")

# run asyncronously
data_url <- paste0("https://www.googleapis.com/dfareporting/v3.4/userprofiles/", dcm_user_id, "/ads")

dcm_report <- GET(data_url, config(token = google_token))


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source