Closed ankitnagarsheth closed 3 years ago
Apparently the client_id and client_secret variables are not being read into the function call. Did you add those 2 items to the .Renviron file? Once you have those 2 variables defined in the .Renviron file you will restart the R session and then reload 'library(adobeanalyticsr)' and you should be able to use 'aw_token()'. After you log in to adobe you well be redirected to adobeanalyticsr.com/token_results.html where you will be able to copy the token string and then paste it into the console after "Enter authorization code:"
Thanks @benrwoodard
I am now in. I had to use this to get the correct usethis::edit_r_environ()
Now, I am getting this 403 error when I try to access using any of aw_ methods
Great! The 403 error is due to the fact that Sys.getenv("AW_REPORTSUITE_ID")
is not returning a value so it sends a blank 'rsid' value to the API. I believe all you need to do is set the AW_REPORTSUITE_ID
variable in the .Renviron file and restart your R session.
Do not use the same function you used earlier or it may overwrite the .Renviron file you already created. I normally just edit the file by clicking on it and opening up in the Rstudio source editor.
You can find the existing .Renviron file that usethis::edit_r_environ()
created in the "Files" tab. This is the way mine looks:
The format of variables in the .Renviron file is straightforward. If you add all four of the variables, they would simply each be their own line in the file:
AW_CLIENT_ID = "[OAuth client ID]"
AW_CLIENT_SECRET = "[OAuth client secret]"
AW_COMPANY_ID = "[Company ID]"
AW_REPORTSUITE_ID = "[RSID]"
If all those are in place then save the file and restart the session, load the library again and try the aw_get_dimensions()
again. You should be good to go.
I'll just chime in that, if you are working with multiple different companies (multiple company_id
s) and/or multiple report suites, you can always pass one or both explicitly within any of the aw_
functions.
And, of course, you can set AW_COMPANY_ID
and/or AW_REPORTSUITE_ID
in your .Renviron
file as your "main/default" values and then, as needed, override them in specific function calls with the company_id
and rsid
arguments that are part of most of the aw_
functions.
@benrwoodard Thanks for the info. I updated the. Renviron and it works fine now :) Appreciate it
@gilliganondata Thanks for the idea of the function. I would like to use the function for different report suite ids.
@gilliganondata @benrwoodard Let me know how can I improve the below function
`rs <- data.frame(cl = "reportsuite1",c2= "reportsuite2")
test_function <- function(rs_value) { t1<- aw_get_metrics(rs_value) } test_function((rs_value = "c(rs$c1,rs$c2)"))
df_test <- map_df(rs,test_function) View(df_test) `
That would work, I think. We've strayed a bit from the original issue at this point.
I was really more just calling out that rsid
and company_id
are available arguments for most of the aw_
functions natively.
For instance:
aw_get_metrics(
rsid = Sys.getenv("AW_REPORTSUITE_ID"),
locale = "en_US",
segmentable = "NULL",
expansion = NA,
company_id = Sys.getenv("AW_COMPANY_ID"),
debug = FALSE,
use_oob = TRUE
)
Note that rsid
, if not explicitly specified, looks for an environment variable called AW_REPORTSUITE_ID
(typically, that would be set in the .Renviron
file as Ben noted, but there are other ways it could be set, too, I believe). Initially, that did not exist, and you were getting a 403
error. I was just saying that, if you set it as an environment variable, you could always specify a different RSID when the function actually gets called—whether it's called one-time or called within another function (as in your example above).
The same goes for company_id
.
This is great Tim..That's very helpful info.Setting in an environment variable works fine too..I will experiment with that. But this issue is resolved. :)
Thanks Ankit
On Thursday, February 4, 2021, Tim Wilson notifications@github.com wrote:
That would work, I think. We've strayed a bit from the original issue at this point.
I was really more just calling out that rsid and companyid are available arguments for most of the aw functions natively.
For instance:
aw_get_metrics(
rsid = Sys.getenv("AW_REPORTSUITE_ID"),
locale = "en_US",
segmentable = "NULL",
expansion = NA,
company_id = Sys.getenv("AW_COMPANY_ID"),
debug = FALSE,
use_oob = TRUE
)
Note that rsid, if not explicitly specified, looks for an environment variable called AW_REPORTSUITE_ID (typically, that would be set in the .Renviron file as Ben noted, but there are other ways it could be set, too, I believe). Initially, that did not exist, and you were getting a 403 error. I was just saying that, if you set it as an environment variable, you could always specify a different RSID when the function actually gets called—whether it's called one-time or called within another function (as in your example above).
The same goes for company_id.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/benrwoodard/adobeanalyticsr/issues/74#issuecomment-773675495, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD7GYPFPMCKF2NO2CD2B5N3S5MV4RANCNFSM4XDDK2QQ .
-- Ankit
@benrwoodard When I try to get authorization token using below .I get error in the screenshot
aw_token()
Browser url = https://ims-na1.adobelogin.com/ims//authorize/v2?client_id=&scope=openid%2CAdobeID%2Cread_organizations%2Cadditional_info.projectedProductContext%2Cadditional_info.job_function&redirect_uri=https%3A%2F%2Fadobeanalyticsr.com%2Ftoken_result.html&response_type=code