{
"kind": "dfareporting#userProfile",
"etag": ...,
"profileId": ...,
"userName": ...,
"accountId": ...,
"accountName": ...,
"subAccountId": "...,
"subAccountName": ...,
}2) Valid profile ID, invalid OAuth2 access token => Error code 401: Login Required
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization",
"debugInfo": ...,
}
],
"code": 401,
"message": "Login Required"
}
}3) Invalid profile ID, valid OAuth2 access token => Error code 400: Invalid profileId{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "Invalid profileId.",
"debugInfo": ...,
}
],
"code": 400,
"message": "Invalid profileId."
}
}
Let me know this doesn't solve your problem! I've be happy to help more.Hi DFA Team,
I hope you are able to help. I'm writing an .NET application which have to run and download a report from report builder. Sounds not complicated so far but every time I'm trying to load the userProfile resource (for testing) then I get an "Invalid profileId." response.
This is the background about implementation and configuration of my application.
1. I'm not using the Google API for authorization. I'm using my own implementation as described here. The authorization seems to work because an access token will be returned and the token info (https://www.googleapis.com/oauth2/v1/tokeninfo?access_token={GENERATED TOKEN}) says that the token is fine:
{
"issued_to": "CLIENT ID",
"audience": "CLIENT ID",
"scope": "https://www.googleapis.com/auth/dfareporting",
"expires_in": 2174,
"access_type": "offline"
}
2. When I'm trying to get the profile info (https://www.googleapis.com/dfareporting/v1/userprofiles/{profileId}?access_token={GENERATED TOKEN}) as described here then the following response will be returned:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "Invalid profileId."
}
],
"code": 400,
"message": "Invalid profileId."
}
}
3. When I use the Try it! form then everything works as expected. When I use the access token generated by the Try it! form to get the userProfile resource as follows then everything works as expected, too.
https://www.googleapis.com/dfareporting/v1/userprofiles/816277?access_token={TOKEN FROM TRY IT FORM}
Why the access token generated by the application doesn't work?
Thanks!
Hi Joseph!
Thanks to you, I know what's the problem now but I'm still not able to solve it. The APIs Console and the Report Builder will be managed with the same Google Account. When I login into Report Builder I'm able to choose the profile I would like to get the data from. When I go to the profile details at "Trafficking" then the check box "Linked to Google Account {MY ACCOUNT}" is checked. This means the profile is associated with the Google Account, right?
I compared the token info of both tokens (application token and Try It form token) and have noticed that the fields "issued_to" and "audience" are different. The application token info contains the client ID which I have created at the APIs Console. That's the same client ID which will be used to create the access token. The Try It form token info contains a different client ID. I don't know where the client ID comes from. Do you have an explanation for the different token infos?
Thanks in advance!
Hi Joseph,
don't know why I didn't had the idea to list user profiles :-) However the response doesn't contain any profile:
{
"kind": "dfareporting#userProfileList",
"etag": "{THE ETAG}",
"items": []
}
I compared the application token with the Try-It! token and noticed that they are different. The application tokens always starts with "1/" but the Try-It! tokens always starts with "ya29.".
As I mentioned in my first post I don't use any Google libraries. The OAuth2 procedure (JWT, etc.) has been implemented myself as described here. I attached my OAuth2 code. Maybe you are right and my OAuth2 code contains errors. Could you have a look please? If you would like to run this code then change the code at line 135 in OAuth2Manager.cs first. I need to subtract 2 hours to get UTC time.
Thanks,
Eugen
{
"iss":"761326798069-r5mljlln1...@developer.gserviceaccount.com",
"scope":"https://www.googleapis.com/auth/devstorage.readonly",
"aud":"https://accounts.google.com/o/oauth2/token",
"exp":1328554385,
"iat":1328550785
}Hi Joseph,
I was on vacation the last few days, that's why I didn't have answered you.
Yes, I'm using a Service Account for DFA API calls. Why the API doesn't answer that the account (or token) doesn't have the rights to make DFA API calls? This would save a lot of our time :-)
Seems that I didn't have seen the chapter about delegated access, that's why I didn't have used the "prn" parameter before.
I tried to append the "prn" parameter but I have got the following response.
{"error" : "access_denied"}
The documentation says that I need a domain administrator account to permit a user to make DFA API calls. As far as I know I don't have a domain administrator account. I think that's the reason why I can't find the configuration section described here.
Do you know how to solve the problem?
Best regards,
Eugen
Am Freitag, 7. September 2012 17:31:10 UTC+2 schrieb dfaapiadv...@google.com:
Hello again!It was not too late. I got a trace and I think I know what your problem is. Are you trying to use Service Accounts?It looks to me like you have a JWT token for a Service Account, but then have not requested delegated access. Take a look at the JWT documentation here: https://developers.google.com/accounts/docs/OAuth2ServiceAccount#formingclaimsetThe first example JWT claim set looks like this: (This is the example from the docs, nothing specific to your app)
{ "iss":"761326798069-r5mljlln1rd4lrbhg75efgigp36m78j...@developer.gserviceaccount.com", "scope":"https://www.googleapis.com/auth/devstorage.readonly", "aud":"https://accounts.google.com/o/oauth2/token", "exp":1328554385, "iat":1328550785 }Not that the "iss" is a gserviceaccount. Your request to the DFA Reporting API is authenticated as something similar to this, "{your service acco...@developer.gserviceaccount.com". Since no DFA user profiles belong to this address, you're getting no access in the DFA Reporting API.