SDITools / adobeanalyticsr

R Client for Adobe Analytics API v2.0
Other
18 stars 9 forks source link

Error when trying to pull data: Forbidden (HTTP 403). #146

Open davidanalyst opened 2 years ago

davidanalyst commented 2 years ago

Hello, thanks for maintaining and improving this package!

I have come across an error that I'm unsure how to fix. I have used Oauth in the past and everything worked fine, but this time around it didn't. I then used JWT, and the connection was established:

SuccessfulJWTConnection

However, when I try to pull metrics/dimensions/segments, I get a 403 error:

image

I have developer access in Adobe Analytics, and I have successfully pulled data before (only using Oauth, not with JWT like this time) Why would I not be allowed to pull data after a successful authentication?

Thanks in advance for your help!

benrwoodard commented 2 years ago

We actually just had another JWT auth issue #145 just like this. The solution was to change from 'developer' to 'admin' and aw_workspace_report should work correctly.

The reason why your auth will be successful but the workspace report won't work is permissions. Authentication is handled via the AEP API and the data is handled via the CJA API.

Let me know if you have any other issues after you make that permission change.

Thanks

davidanalyst commented 2 years ago

Hi Ben, thanks for your quick response.

I actually had both admin and developer permissions. Is there a specific product I should have permission for as an 'admin'?

Thank you.

davidanalyst commented 2 years ago

Strangely enough, aw_freeform_table() seems to work, but aw_get_segments, or aw_get_metrics() gives the 403 error. Not sure how to interpret this.

OmarGonD commented 2 years ago

Have same issue:

1.- at 5 pm. at laptop work, I could authenticate and download data (OATH method). First time setting the library in work laptop.

2.- 10 pm at home, on my PC that I've used a couple of weeks before to pull data, and can authenticate but not pull data...

> library(adobeanalyticsr)
> aw_auth_with('oauth')
> aw_auth()
Successfully authenticated with OAuth
> aa <- aw_freeform_table(
+   company_id = Sys.getenv("AW_COMPANY_ID"),
+   rsid = Sys.getenv("AW_REPORTSUITE_ID"),
+   date_range = c("2022-08-14", "2022-08-15"),
+   dimensions = c("campaign"),
+   metrics = c("visits"),
+   top = c(1032),
+   page = 0,
+   filterType = "breakdown",
+   segmentId = NA,
+   metricSort = "desc",
+   include_unspecified = TRUE,
+   search = NA,
+   prettynames = FALSE,
+   debug = FALSE,
+   check_components = TRUE
+ )
Auto-refreshing stale OAuth token.
Error in refresh_oauth2.0(self$endpoint, self$app, self$credentials, self$params$user_params, : Bad Request (HTTP 400).
Request failed [ERROR]. Retrying in 1.1 seconds...
Auto-refreshing stale OAuth token.
Error in refresh_oauth2.0(self$endpoint, self$app, self$credentials, self$params$user_params, : Bad Request (HTTP 400).
Request failed [ERROR]. Retrying in 1 seconds...
Auto-refreshing stale OAuth token.
Error in refresh_oauth2.0(self$endpoint, self$app, self$credentials, self$params$user_params,  : 
  Bad Request (HTTP 400).
benrwoodard commented 2 years ago

This may be a result of the new(er) profiles that Adobe has been luanching. If you are able to use the function "get_me()" then make sure the company id/name is showing that you are wanting to pull data from. If it does pull back information but your company id/name is not showing then you may be experiencing the new profile issue that we have seen internally in our company as well. This requires you to log out of adobe and then attempt to re-auth by signing back in and choosing the correct profile.
If, on the other hand, you are not able to pull information using 'get_me()' then you may have an expired 'aa.oauth' file and have to manually delete it and then re-authorize. The Adobe API does not allow us to refresh the oauth token so we need to re-auth manually every 24 hours.
Finally, if you are able to pull information using 'get_me()' and the company name/id is showing but you are still not able to pull data from the report suite then it may be a permissions issue and you would need to research to make sure you have the permission access level needed to use the API.