def get_client(credentials, network_code=None): """Returns a DFP API client instance for a specific network.""" return dfp.DfpClient(RefreshClient(credentials), application_name=env.DFP_APP_NAME, network_code=network_code, enable_compression=True, cache=MemcacheCache())
def main(access_token, token_expiry, application_name): oauth2_client = oauth2.GoogleAccessTokenClient(access_token, token_expiry) dfp_client = dfp.DfpClient(oauth2_client, application_name) networks = dfp_client.GetService('NetworkService').getAllNetworks() for network in networks: print( 'Network with network code "%s" and display name "%s" was found.' % (network['networkCode'], network['displayName']))
def main(service_account_email, key_file, application_name): oauth2_client = oauth2.GoogleServiceAccountClient( oauth2.GetAPIScope('dfp'), service_account_email, key_file) dfp_client = dfp.DfpClient(oauth2_client, application_name) networks = dfp_client.GetService('NetworkService').getAllNetworks() for network in networks: print ('Network with network code \'%s\' and display name \'%s\' was found.' % (network['networkCode'], network['displayName']))
def __init__(self, service_account_email, key_file, application_name): oauth2_client = oauth2.GoogleServiceAccountClient( oauth2.GetAPIScope('dfp'), service_account_email, key_file) self.dfp_client = dfp.DfpClient(oauth2_client, application_name, NETWORK) self.custom_targeting_service = self.dfp_client.GetService( 'CustomTargetingService', version='v201505') self.search_for_order(raw_input("Search for the order: "))
def main(client_id, client_secret, refresh_token, application_name): oauth2_client = oauth2.GoogleRefreshTokenClient(client_id, client_secret, refresh_token) dfp_client = dfp.DfpClient(oauth2_client, application_name) networks = dfp_client.GetService('NetworkService').getAllNetworks() for network in networks: print(( 'Network with network code \'%s\' and display name \'%s\' was found.' % (network['networkCode'], network['displayName'])))
def load_client(): global _client if not _client: oauth2_client = oauth2.GoogleServiceAccountClient( oauth2.GetAPIScope("dfp"), g.dfp_service_account_email, KEY_FILE, ) _client = dfp.DfpClient(oauth2_client, g.dfp_project_id) _client.network_code = g.dfp_test_network_code if g.debug else g.dfp_network_code
path = 'C:/Users/christopher.brossman/Documents/Projects/work/newDFP/python/' keyName = 'DFP service Account-ec3f20e59362.p12' key_file_path = path + keyName passwd = 'notasecret' serviceAccountId = '*****@*****.**' application_name = 'brossmanPython' from googleads import dfp from googleads import oauth2 # Initialize the GoogleRefreshTokenClient using the credentials you received # in the earlier steps. oauth2_client = oauth2.GoogleServiceAccountClient(oauth2.GetAPIScope('dfp'), serviceAccountId, key_file_path) # Initialize the DFP client. dfp_client = dfp.DfpClient( oauth2_client, application_name)