0

I am trying to create a python script to ingest data into dv360. Its a script that just runs - its not a web app for instance. Thus I would assume its defined as a "server to server" application. Though its really a script to server application - is my computer the server in this case?

And thus I think I should be authenticating with a service account. But all the documentation I can find recommends using oauth2 for dv360 instead of a service account. Even inside of oauth2 I see that there is a delineation between installed oath and server to server oauth.

Can anyone who has experience with the dv360 api tell me what my application described above would be classified as and whether I need a service account, oath for installed apps, or oath for server to server apps in order to authenticate?

BigBoy1337
  • 4,735
  • 16
  • 70
  • 138

1 Answers1

1

For your use case OAuth 2.0 for Server to Server Applications is recommended.

You can use Google API Python Client library to perform operations on DV360 using service account.

Here is the sample snippet to fetch DV360 Advertisers using this python client library.

import json
from googleapiclient import discovery

# DV360 service
dv360_service = discovery.build('displayvideo', 'v1')

# Get Advertiser Info
data = {'advertiserId': '1234567'}
response = dv360_service.advertisers().get(**data).execute()
print(json.dumps(response, indent=2))

Output:

{
  "name": "advertisers/1234567",
  "advertiserId": "1234567",
  "partnerId": "8901234",
  "displayName": "LoremIpsum",
  "entityStatus": "ENTITY_STATUS_PAUSED",
  "updateTime": "2022-10-14T04:46:31.291Z",
  "generalConfig": {
    "domainUrl": "https://www.example.com",
    "timeZone": "Asia/Calcutta",
    "currencyCode": "INR"
  },
  "adServerConfig": {
    "thirdPartyOnlyConfig": {
      "pixelOrderIdReportingEnabled": true
    }
  },
  "creativeConfig": {},
  "dataAccessConfig": {
    "sdfConfig": {
      "sdfConfig": {
        "version": "SDF_VERSION_5_2"
      }
    }
  },
  "integrationDetails": {},
  "servingConfig": {
    "exemptTvFromViewabilityTargeting": true
  }
}

Make sure to set GOOGLE_APPLICATION_CREDENTIALS environment variable with path/to/service-account-key.json before running the script

e.g. GOOGLE_APPLICATION_CREDENTIALS='/home/dikesh/.keys/service-key.json' python test.py

dikesh
  • 2,977
  • 2
  • 16
  • 26