-
Notifications
You must be signed in to change notification settings - Fork 979
API access using own credentials (server to server flow)
nicholaschen edited this page May 26, 2016
·
7 revisions
This guide will walk you through how to setup OAuth2 for API access using your own credentials using server to server flow.
Follow the steps for the product you're using to generate a *service account ID and a .p12 file, then come back to this page.
If you're an AdWords user, please note that this flow requires a Google Apps Domain.
-
You can now initialize either an
AdWordsClient
orDfpClient
using the *service account email and .p12 file you received in the last step. To do so, you should provide an initializedGoogleServiceAccountClient
to the AdWords/DFP client via theoauth2_client
argument during initialization.For example, if you need to set up a DfpClient, it may look something like the following:
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'), service_account_email, key_file_path) # Initialize the DFP client. dfp_client = dfp.DfpClient( oauth2_client, application_name)