API access for DCM / DFA reporting and Trafficking API

1,501 views
Skip to first unread message

Jack Kwakman

unread,
Jan 5, 2017, 9:16:06 AM1/5/17
to Google's DoubleClick Campaign Manager API Forum
Dear Google Team member or fellow group member,

After finalizing software for the Google Analytics API based on the Google_Client libraries i thought a secondary library for retrieving data from the DFA reporting and Trafficking API would be easy. I use the same account and verified in the API console that i have access to the DFA reporting and Trafficking API. I am able to login with this account in DFA and have full access to the account data. Google Analytics data can be requested so technically everything works.

But if i try the API call for listing the userProfiles ( $this->service->userProfiles->listUserProfiles() ) i get no results. So it basically says that i have no allowed DFA userprofiles but i am able to login into DFA. 

Do i have to do something special to activate the API methods for DFA? Or are there any other unkown (at least for me) prerequisites?

Kind regards,

Jack Kwakman

Lakshmi(DCM API Team)

unread,
Jan 5, 2017, 3:02:23 PM1/5/17
to Google's DoubleClick Campaign Manager API Forum
Hi Jack,

Please check this prerequisites document in order to get programmatic access to a DCM account. As mentioned in the linked document for enabling API access, please contact DCM product support or general support team.

Once it is enabled, you can test in this try-it section.

Thanks,
Lakshmi, DCM API Team

Jack Kwakman

unread,
Jan 6, 2017, 2:49:44 AM1/6/17
to Google's DoubleClick Campaign Manager API Forum
Dear Lakshmi,

Thank you for the quick reply. I already e-mailed general support and they forwarded my question to the API team (4-1992000015149). I think this will end up with you guys so maybe it is faster to post it in this group :)

I am able to make requests and receive data via the try-it section so this works. But i want to use the service account mode. Here i can make requests but do not receive any data.

I checked the prerequisites page below:
https://developers.google.com/doubleclick-advertisers/service_accounts

One prerequisite i am missing is the gsuite account. My question is:

- Should i register for a gsuite account and grant access with tthis account to DCM/DFA? Would this allow me to receive data with a service account?
- Can all the other users (none gsuite accounts) still have access to the DCM/DFA ui? Or should everybody use a gsuite account from this day on?

I hope you can answer my questions..

Kind regards,

Jack Kwakman

Op donderdag 5 januari 2017 21:02:23 UTC+1 schreef Lakshmi(DCM API Team):

Jack Kwakman

unread,
Jan 10, 2017, 2:58:17 AM1/10/17
to Google's DoubleClick Campaign Manager API Forum
For future reference i post the private reply i got from the API team.

Kind regards,

Jack Kwakman


Hi Jack,

Thanks for getting back. The try-it where you were testing was with a non-service account (since you logged in as xx...@xxx.com). 

To utilize service account, you will need G Suite accounts as you said. Preferably the whole domain should be registered with G Suite, so that all users within the domain can use impersonation abilities on behalf of others.

Vu

Op vrijdag 6 januari 2017 08:49:44 UTC+1 schreef Jack Kwakman:

scang...@forbes.com

unread,
Jan 30, 2018, 1:27:42 PM1/30/18
to Google's DoubleClick Campaign Manager API Forum
Same issue here. Can someone explain to me what this means:
Check user profile permissions in the DCM UI. These control what the user profile can access from the API. There are no separate API permissions.

from:
https://developers.google.com/doubleclick-advertisers/getting_started#prerequisites

Where is that page?



On Thursday, January 5, 2017 at 9:16:06 AM UTC-5, Jack Kwakman wrote:

Lakshmi Prathipati (DCM API Team)

unread,
Jan 30, 2018, 3:11:41 PM1/30/18
to Google's DoubleClick Campaign Manager API Forum
Hi, 

Please check this permissions help center article. You need to login with your Google account in order to view the help center articles. They are not the API documents. For any further questions, please start a new thread.

Thanks,
Lakshmi, DCM API Team

omkar....@yuktamedia.com

unread,
Jun 27, 2018, 3:10:45 PM6/27/18
to Google's DoubleClick Campaign Manager API Forum
Dear Google Team member,

I have used php library v3.1 to get  DFA reporting data from API. i have created Web Application(APis & services -> oAuth Client id -> Web Application) and i can get data from API.
but i don't want to login every time and generate session to access APIs. so i have tried Service Account, i have created service account and used its .json file in my program, i can execute my php program without any error but unable to get data. i also used "AuthenticateUsingServiceAccount,php"  sample file and run it using command prompt but i am unable to get any response. please give me solution.

Thank you.

Lakshmi Prathipati (DCM API Team)

unread,
Jun 28, 2018, 3:10:03 PM6/28/18
to Google's DoubleClick Campaign Manager API Forum
Hi,

If you are using service accounts:
  1. As a DCM user: Did you add the service account email as a user profile in the DCM? 
  2. To impersonate an existing profile: Did you enable domain wide delegation?
Could you please start a new thread with all the details? 

omkar....@yuktamedia.com

unread,
Jun 29, 2018, 2:42:20 AM6/29/18
to Google's DoubleClick Campaign Manager API Forum
HI Lakshmi,

I did following steps.

1)  Download all required dependencies using composer, also download new DFA library(v3.1) using 
2)  Using https://console.developers.google.com/apis/credentials? created service account and downloaded client_secrets.json file. in this file have following information.
{
  "type": "service_account",
  "project_id": "",
  "private_key_id": "",
  "private_key": "",
  "client_email": "",
  "client_id": "",
  "auth_provider_x509_cert_url": "",
  "client_x509_cert_url": ""
}
3) Using command line run AuthenticateUsingServiceAccoun.php file which is available in DFA library and passed path of client_secrets.json file. 
    ex. php AuthenticateUsingServiceAccoun.php  ./client_secrets.json
4) It was not return any result. 
5) Debugged AuthenticateUsingServiceAccoun.php files.    
     $result = $service->userProfiles->listUserProfiles();
     var_dump($result);

output : 

object(Google_Service_Dfareporting_UserProfileList)#106 (9) { ["collection_key":protected]=> string(5) "items" ["etag"]=> string(57) ""AIYTFuu4eXftovO-6w8wCMjIH_c/vyGp6PvFo4RvsFtPoIWeCReyIC8"" ["itemsType":protected]=> string(39) "Google_Service_Dfareporting_UserProfile" ["itemsDataType":protected]=> string(5) "array" ["kind"]=> string(28) "dfareporting#userProfileList" ["internal_gapi_mappings":protected]=> array(0) { } ["modelData":protected]=> array(0) { } ["processed":protected]=> array(0) { } ["items"]=> array(0) { } } 

It returns empty *item* array. 

Please let me know am i missed any steps? and yes please send me steps which i need to follow.

and Thank you so much for your replay. :)

Lakshmi Prathipati (DCM API Team)

unread,
Jun 29, 2018, 3:11:47 PM6/29/18
to Google's DoubleClick Campaign Manager API Forum
Hi,

If you are getting an empty response that means there are no user profiles associated with the service account. Are you using the service account as a DCM user or to impersonate the existing users?

omkar....@yuktamedia.com

unread,
Jun 30, 2018, 1:24:20 AM6/30/18
to Google's DoubleClick Campaign Manager API Forum
Hi Lakshmi,

1) If you are getting an empty response that means there are no user profiles associated with the service account. 
-> I am getting all user profiles data in API when i am following steps whis is given in 

- The steps are followed.
- Visit https://console.developers.google.com to register your application.
- From the API Manager -> Overview screen, activate access to "DCM/DFA Reporting and Trafficking API".
- Click on "Credentials" in the left navigation menu
- Click the button labeled "Create credentials" -> "OAuth2 client ID"
- Select "Web Application" as the "Application type"
- Configure javascript origins and redirect URIs
  - Authorized Javascript Origins: http://localhost
  - Authorized Redirect URIs: http://localhost/path/to/index.php
- Click "Create client ID"
- Click "Download JSON" and save the file as client_secrets.json in your examples directory 

Is there any additional settings to associate user profiles with service account?


2) Are you using the service account as a DCM user or to impersonate the existing users?
-> Yes, i am using DCM user and not impersonate the existing users.


Thanks.
Omkar Kamble

Lakshmi Prathipati (DCM API Team)

unread,
Jul 2, 2018, 3:10:59 PM7/2/18
to Google's DoubleClick Campaign Manager API Forum
Hi Omkar,

The reason you are able to see using Application type 'Web application' because the email with which you have generated the credentials might be added as a user in the DCM account. Did you add the service account email address (ends with gserviceaccount.com) as a user in the DCM account as mentioned in this guide (step 2)? 
Reply all
Reply to author
Forward
0 new messages