Authenticate via OAuth Authentication
Use the OAuth authentication standard to connect to Google Ads Manager. You can authenticate with a user account or with a service account. A service account is required to grant organization-wide access scopes to the provider. The provider facilitates these authentication flows as described below.
Authenticate with a User Account
See Using OAuth Authentication for an authentication guide.
Authenticate with a Service Account
Service accounts have silent authentication, without user authentication in the browser. You need to create an OAuth application in this flow. See Creating a Custom OAuth App to create and authorize an app. You can then connect to Google Ads Manager data that the service account app has permission to access.
After setting the following connection properties, you are ready to connect:
- NetworkCode: Set this to the network code displayed in the URL when you are logged into your network. For example, in the URL https://www.google.com/dfp/2032576#delivery, 2032576 is your network code.
- InitiateOAuth: Set this to GETANDREFRESH. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken connection property.
- OAuthJWTCertType: Set this to "PFXFILE".
- OAuthJWTCertPassword: Set this to the password of the .p12 file.
- OAuthJWTCertSubject: Set this to "*" to pick the first certificate in the certificate store.
- OAuthJWTIssuer: Set this to the email address of the service account.
- OAuthJWTCert: Set this to the path to the .p12 file.
- OAuthJWTSubject: Set this to the email address of the user for whom the application is requesting delegate access. Note that delegate access must be granted by an administrator.
When you connect the provider completes the OAuth flow for a service account.
- Creates and signs the JWT with the claim set required by the provider.
- Exchanges the JWT for the access token.
- Saves OAuth values in OAuthSettingsLocation to be persisted across connections.
- Submits the JWT for a new access token when the token expires.
Using OAuth Authentication
Use the OAuth authentication standard to connect to Google Ads Manager. You can authenticate with a user account or a service account. The provider facilitates this as described below.
Using a User Account to Authenticate to Google Ads Manager
The user account flow requires the authenticating user to interact with Google Ads Manager via the browser.
Embedded Credentials
Desktop Applications
See Embedded Credentials to connect with the provider's embedded credentials and skip creating a custom OAuth app.Headless Machines
See Headless Machines to skip creating a custom OAuth app and authenticate an application running on a headless server or another machine where the provider is not authorized to open a browser.Custom Credentials
Instead of connecting with the provider's embedded credentials, you can register an app to obtain the OAuthClientId and OAuthClientSecret.
When to Create a Custom OAuth App
Web Applications
You need to create a custom OAuth app in the web flow.
Desktop Applications
Creating a custom OAuth app is optional as the provider is already registered with Google Ads Manager and you can connect with its embedded credentials. You might want to create a custom OAuth app to change the information displayed when users log into the Google Ads Manager OAuth endpoint to grant permissions to the provider.
Headless Machines
Creating a custom OAuth app is optional to authenticate a headless machine; the provider is already registered with Google Ads Manager and you can connect with its embedded credentials. In the headless OAuth flow, users need to authenticate via a browser on another machine. You might want to create a custom OAuth app to change the information displayed when users log into the Google Ads Manager OAuth endpoint to grant permissions to the provider.
Using a Service Account to Connect to Google Ads Manager
Service accounts have silent authentication, without user authentication in the browser. You can also use a service account to delegate enterprise-wide access scopes to the provider.
You need to create an OAuth application in this flow. You can then connect to Google Ads Manager data that the service account has permission to access. See Custom Credentials for an authentication guide.
Creating a Custom OAuth App
See Creating a Custom OAuth App for a procedure.
Embedded Credentials
Authenticate using the Embedded OAuth Credentials
Desktop Authentication with the Embedded OAuth App
You can connect without setting any connection properties for your user credentials. After setting the following, you are ready to connect:
- InitiateOAuth: Set this to GETANDREFRESH. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken.
- NetworkCode: Set the NetworkCode connection property to the network code displayed in the URL when you are logged into your network. For example, in the URL https://www.google.com/dfp/2032576#delivery, 2032576 is your network code.
- Extracts the access token from the callback URL and authenticates requests.
- Obtains a new access token when the old one expires.
- Saves OAuth values in OAuthSettingsLocation to be persisted across connections.
Custom Credentials
When to Create a Custom OAuth App
User Account Authentication
Creating a custom OAuth app is required in the web flow. Creating a custom OAuth app is optional for desktop and headless applications; the provider is already registered with Google Ads Manager and you can connect with its embedded credentials.You might want to create a custom OAuth app to change the information displayed when users log into the Google Ads Manager OAuth endpoint to grant permissions to the provider.
Service Account Authentication
You need to create an OAuth app in the service account flow.
Authenticate with a User Account
Desktop Authentication with a Custom OAuth App
After Creating a Custom OAuth App, follow the steps below to authenticate with your custom App's credentials.Get and Refresh the OAuth Access Token
After setting the following, you are ready to connect:
- OAuthClientId: Set this to the client Id assigned when you registered your app.
- OAuthClientSecret: Set this to the client secret assigned when you registered your app.
- InitiateOAuth: Set this to GETANDREFRESH. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken.
- NetworkCode: Set the NetworkCode connection property to the network code displayed in the URL when you are logged into your network. For example, in the URL https://www.google.com/dfp/2032576#delivery, 2032576 is your network code.
- Extracts the access token from the callback URL and authenticates requests.
- Refreshes the access token when it expires.
- Saves OAuth values in OAuthSettingsLocation to be persisted across connections.
Web Authentication with a Custom OAuth App
When connecting via a Web application, you need to register a custom OAuth app with Google Ads Manager; see Creating a Custom OAuth App. You can then use the provider to get and manage the OAuth token values.
Get an OAuth Access Token
Set the following connection properties to obtain the OAuthAccessToken:
- OAuthClientId: Set this to the Client Id in your app settings.
- OAuthClientSecret: Set this to the Client Secret in your app settings.
- NetworkCode: Set the NetworkCode connection property to the network code displayed in the URL when you are logged into your network. For example, in the URL https://www.google.com/dfp/2032576#delivery, 2032576 is your network code.
You can then call stored procedures to complete the OAuth exchange:
-
Call the GetOAuthAuthorizationURL stored procedure. Set the AuthMode input to WEB and set the CallbackURL input to the Redirect URI you specified in your app settings.
The stored procedure returns the URL to the OAuth endpoint.
- Open the URL, log in, and authorize the application. You are redirected back to the callback URL.
- Call the GetOAuthAccessToken stored procedure. Set the AuthMode input to WEB. Set the Verifier input to the "code" parameter in the query string of the callback URL.
Refresh the OAuth Access Token
You can set InitiateOAuth to REFRESH to automatically refresh the OAuth access token when it expires, or you can call the RefreshOAuthAccessToken stored procedure to refresh the token manually.
Automatic Refresh
To refresh the token with InitiateOAuth, set the following on the first data connection:
- OAuthAccessToken: Set this to the access token returned by GetOAuthAccessToken.
- InitiateOAuth: Set this to REFRESH. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken.
- OAuthSettingsLocation: Set this to the path where the provider will save the OAuth values, to be persisted across connections.
- OAuthClientId: Set this to the Client Id in your app settings.
- OAuthClientSecret: Set this to the Client Secret in your app settings.
- OAuthRefreshToken: Set this to the refresh token returned by GetOAuthAccessToken.
- NetworkCode: Set the NetworkCode connection property to the network code displayed in the URL when you are logged into your network. For example, in the URL https://www.google.com/dfp/2032576#delivery, 2032576 is your network code.
On subsequent data connections, set the following:
- InitiateOAuth
- OAuthSettingsLocation
- NetworkCode
Manual Refresh
You can use the RefreshOAuthAccessToken stored procedure to manually refresh the OAuthAccessToken. Call the stored procedure after the ExpiresIn parameter value returned by GetOAuthAccessToken has elapsed. You need the following connection properties to be set:
- OAuthClientId: Set this to the Client Id in your app settings.
- OAuthClientSecret: Set this to the Client Secret in your app settings.
- NetworkCode: Set the NetworkCode connection property to the network code displayed in the URL when you are logged into your network. For example, in the URL https://www.google.com/dfp/2032576#delivery, 2032576 is your network code.
You can then call RefreshOAuthAccessToken with the following parameter set:
- OAuthRefreshToken: Set this to the OAuthRefreshToken returned by GetOAuthAccessToken.
Authenticate with a Service Account
Service accounts have silent authentication, without user authentication in the browser. You can also use a service account to grant enterprise-wide access scopes to the provider.
You need to create an OAuth application in this flow. See Creating a Custom OAuth App to create and authorize an app.
You can then connect to Google Ads Manager data that the service account has permission to access. After setting the following connection properties, you are ready to connect:
- InitiateOAuth: Set this to GETANDREFRESH.
- OAuthClientId: Set this to the Client Id in your app settings.
- OAuthClientSecret: Set this to the Client Secret in your app settings.
- OAuthJWTCertType: Set this to "PEMKEY_FILE".
- OAuthJWTCert: Set this to the path to the .pem file you generated.
- OAuthJWTCertPassword: Set this to the password of the .pem file.
- OAuthJWTCertSubject: Set this to "*" to pick the first certificate in the certificate store.
- OAuthJWTSubject: Set this to your enterprise Id if your subject type is set to "enterprise" or your app user Id if your subject type is set to "user".
- NetworkCode: Set the NetworkCode connection property to the network code displayed in the URL when you are logged into your network. For example, in the URL https://www.google.com/dfp/2032576#delivery, 2032576 is your network code.
- Creates and signs the JWT with the claim set required by the provider.
- Exchanges the JWT for the access token.
- Saves OAuth values in OAuthSettingsLocation to be persisted across connections.
- Submits the JWT for a new access token when the token expires.
Headless Machines
Using OAuth on a Headless Machine
The following sections show how to authenticate a headless server or another machine on which the provider cannot open a browser. You can authenticate with a user account or with a service account.Authenticate with a User Account
To authenticate with a user account, you need to authenticate from another machine. Authentication is a two-step process.- Instead of installing the provider on another machine, you can follow the steps below to obtain the OAuthVerifier value. Or, you can install the provider on another machine and transfer the OAuth authentication values, after you authenticate through the usual browser-based flow.
- You can then configure the provider to automatically refresh the access token from the headless machine.
Using the Embedded OAuth Credentials
Obtain a Verifier Code
Follow the steps below to authenticate from another machine and obtain the OAuthVerifier connection property:
- Click the following link to open the Google Ads Manager OAuth endpoint in your browser.
- Log in and grant permissions to the provider. You are then redirected to the callback URL, which contains the verifier code.
- Save the value of the verifier code. You will set this in the OAuthVerifier connection property.
On the headless machine, set the following connection properties to obtain the OAuth authentication values.
- OAuthVerifier: Set this to the verifier code.
- InitiateOAuth: Set this to REFRESH.
- OAuthSettingsLocation: Set this to persist the encrypted OAuth authentication values to the specified file.
- NetworkCode: Set the NetworkCode connection property to the network code displayed in the URL when you are logged into your network. For example, in the URL https://www.google.com/dfp/2032576#delivery, 2032576 is your network code.
After the OAuth settings file is generated, set the following properties to connect to data:
- OAuthSettingsLocation: Set this to the file containing the encrypted OAuth authentication values. Make sure this file gives read and write permissions to the provider to enable the automatic refreshing of the access token.
- InitiateOAuth: Set this to REFRESH.
- NetworkCode: Set the NetworkCode connection property to the network code displayed in the URL when you are logged into your network. For example, in the URL https://www.google.com/dfp/2032576#delivery, 2032576 is your network code.
Transfer OAuth Settings
Follow the steps below to install the provider on another machine, authenticate, and then transfer the resulting OAuth values.
On a second machine, install the provider and connect with the following properties set:
- OAuthSettingsLocation: Set this to a writable text file.
- InitiateOAuth: Set this to GETANDREFRESH.
- NetworkCode: Set the NetworkCode connection property to the network code displayed in the URL when you are logged into your network. For example, in the URL https://www.google.com/dfp/2032576#delivery, 2032576 is your network code.
On the headless machine, set the following connection properties to connect to data:
- InitiateOAuth: Set this to REFRESH.
- OAuthSettingsLocation: Set this to the path to your OAuth settings file. Make sure this file gives read and write permissions to the provider to enable the automatic refreshing of the access token.
- NetworkCode: Set the NetworkCode connection property to the network code displayed in the URL when you are logged into your network. For example, in the URL https://www.google.com/dfp/2032576#delivery, 2032576 is your network code.
Using the Credentials for a Custom OAuth App
Create a Custom OAuth App
Creating a custom OAuth app is optional in the headless OAuth flow; you can skip creating an app by connecting with the provider's embedded OAuth credentials. You might want to create a custom OAuth app to change the information displayed when users log into Google Ads Manager to grant permissions to the provider.
See Creating a Custom OAuth App for a procedure. You can then follow the procedures below to authenticate and connect to data.
Obtain a Verifier Code
Set the following properties on the headless machine:
- InitiateOAuth: Set this to OFF.
- OAuthClientId: Set this to the Client Id in your app settings.
- OAuthClientSecret: Set this to the Client Secret in your app settings.
- NetworkCode: Set the NetworkCode connection property to the network code displayed in the URL when you are logged into your network. For example, in the URL https://www.google.com/dfp/2032576#delivery, 2032576 is your network code.
You can then follow the steps below to authenticate from another machine and obtain the OAuthVerifier connection property.
- Call the GetOAuthAuthorizationURL stored procedure with the CallbackURL input parameter set to the exact Redirect URI you specified in your app settings.
- Open the returned URL in a browser. Log in and grant permissions to the provider. You are then redirected to the callback URL, which contains the verifier code.
- Save the value of the verifier code. You will set this in the OAuthVerifier connection property.
On the headless machine, set the following connection properties to obtain the OAuth authentication values:
- OAuthVerifier: Set this to the verifier code.
- OAuthSettingsLocation: Set this to persist the encrypted OAuth authentication values to the specified file.
- InitiateOAuth: Set this to REFRESH.
- NetworkCode: Set the NetworkCode connection property to the network code displayed in the URL when you are logged into your network. For example, in the URL https://www.google.com/dfp/2032576#delivery, 2032576 is your network code.
After the OAuth settings file is generated, set the following properties to connect to data:
- OAuthSettingsLocation: Set this to the file containing the encrypted OAuth authentication values. Make sure this file gives read and write permissions to the provider to enable the automatic refreshing of the access token.
- InitiateOAuth: Set this to REFRESH.
- NetworkCode: Set the NetworkCode connection property to the network code displayed in the URL when you are logged into your network. For example, in the URL https://www.google.com/dfp/2032576#delivery, 2032576 is your network code.
Transfer OAuth Settings
Follow the steps below to install the provider on another machine, authenticate, and then transfer the resulting OAuth values.
On a second machine, install the provider and connect with the following properties set:
- OAuthSettingsLocation: Set this to a writable text file.
- InitiateOAuth: Set this to GETANDREFRESH.
- OAuthClientId: Set this to the client Id assigned when you registered your app.
- OAuthClientSecret: Set this to the client secret assigned when you registered your app.
- NetworkCode: Set the NetworkCode connection property to the network code displayed in the URL when you are logged into your network. For example, in the URL https://www.google.com/dfp/2032576#delivery, 2032576 is your network code.
Test the connection to authenticate. The resulting authentication values are written, encrypted, to the path specified by OAuthSettingsLocation. Once you have successfully tested the connection, copy the OAuth settings file to your headless machine. On the headless machine, set the following connection properties to connect to data:
- InitiateOAuth: Set this to REFRESH.
- OAuthSettingsLocation: Set this to the path to your OAuth settings file. Make sure this file gives read and write permissions to the provider to enable the automatic refreshing of the access token.
- NetworkCode: Set the NetworkCode connection property to the network code displayed in the URL when you are logged into your network. For example, in the URL https://www.google.com/dfp/2032576#delivery, 2032576 is your network code.
Authenticate with a Service Account
Service accounts have silent authentication, without user authentication in the browser. You can also use a service account to delegate enterprise-wide access scopes to the provider.
You need to create an OAuth application in this flow. See Creating a Custom OAuth App to create and authorize an app. You can then connect to Google Ads Manager data that the service account has permission to access.
After setting the following connection properties, you are ready to connect:
- InitiateOAuth: Set this to GETANDREFRESH.
- OAuthClientId: Set this to the Client Id in your app settings.
- OAuthClientSecret: Set this to the Client Secret in your app settings.
- OAuthJWTCertType: Set this to "PEMKEY_FILE".
- OAuthJWTCert: Set this to the path to the .pem file you generated.
- OAuthJWTCertPassword: Set this to the password of the .pem file.
- OAuthJWTCertSubject: Set this to "*" to pick the first certificate in the certificate store.
- OAuthJWTIssuer: In the service accounts section, click Manage Service Accounts and set this field to the email address displayed in the service account Id field.
- OAuthJWTSubject: Set this to your enterprise Id if your subject type is set to "enterprise" or your app user Id if your subject type is set to "user".
- NetworkCode: Set the NetworkCode connection property to the network code displayed in the URL when you are logged into your network. For example, in the URL https://www.google.com/dfp/2032576#delivery, 2032576 is your network code.
- Creates and signs the JWT with the claim set required by the provider.
- Exchanges the JWT for the access token.
- Saves OAuth values in OAuthSettingsLocation to be persisted across connections.
- Submits the JWT for a new access token when the token expires.
Creating a Custom OAuth App
When to Create a Custom OAuth App
User Account Authentication
Creating a custom OAuth app is required in the web flow. Creating a custom OAuth app is optional for desktop and headless applications; the provider is already registered with Google Ads Manager and you can connect with its embedded credentials.You might want to create a custom OAuth app to change the information displayed when users log into the Google Ads Manager OAuth endpoint to grant permissions to the provider.
Service Account Authentication
You need to create an OAuth app in the service account flow.
Create an OAuth App for User Account Authentication
Follow the procedure below to register an app and obtain the OAuthClientId and OAuthClientSecret.Create a Custom OAuth App: Desktop
- Log into the Google API Console and open a project. Select the API Manager from the main menu.
- Click Credentials -> Create Credentials -> OAuth Client Id. Click Other.
After creating the app, the OAuthClientId and OAuthClientSecret are displayed.
Configure Your DFP Network
Follow the steps below to authorize the application; if you are a third-party developer, you may need to have your client perform these steps for you.
- Go to your DoubleClickFP for Publishers network.
- Click the Admin tab.
- Ensure that API access is enabled.
Create a Custom OAuth App: Web Apps
- Log into the Google API Console and open a project. Select the API Manager from the main menu.
- If you are connecting from a Web application, click Web Application. In the Authorized Redirect URIs box, enter the URL you want to be used as a trusted redirect URL, where the user will return with the token that verifies that they have granted your app access.
After creating the app, the OAuthClientId and OAuthClientSecret are displayed.
Configure Your DFP Network
If you are a third-party developer, you may need to have your client do this step for you.
- Go to your DoubleClickFP for Publishers network.
- Click the Admin tab.
- Ensure that API access is enabled.
- Go to your DoubleClickFP for Publishers network.
- Click the Admin tab.
- Ensure that API access is enabled.
Create a Custom OAuth App: Headless Machines
- Log into the Google API Console and open a project. Select the API Manager from the main menu.
- Click Credentials -> Create Credentials -> OAuth Client Id. Click Other
After creating the app, the OAuthClientId and OAuthClientSecret are displayed.
Configure Your DFP Network
Follow the steps below to authorize the application; if you are a third-party developer, you may need to have your client perform these steps for you.
- Go to your DoubleClickFP for Publishers network.
- Click the Admin tab.
- Ensure that API access is enabled.
Create an OAuth App for Service Account Authentication
To obtain the necessary authentication properties, follow the steps below to create an OAuth application and generate a private key:
- Log into the Google API Console and open a project. Select the API Manager from the main menu.
- Click Create Credentials -> Service Account Key.
- In the Service Account menu, select New Service Account or select an existing service account.
- If you are creating a new service account, additionally select one or more roles. You can assign primitive roles at the project level in the IAM and Admin section; other roles enable you to further customize access to Google APIs.
- In the Key Type section, select the P12 key type.
- Create the app to download the key pair. The private key's password is displayed: Set this in OAuthJWTCertPassword.
- In the service accounts section, click Manage Service Accounts and set OAuthJWTIssuer to the email address displayed in the service account Id field.
Configure Your DFP Network
If you are a third-party developer, you may need to have your client do this step for you.
- Go to your DoubleClickFP for Publishers network.
- Click the Admin tab.
- Ensure that API access is enabled.
Follow the steps below to authorize the app; you are then ready to follow the authentication guide.
- Click the Add a Service Account User button.
- Fill in the form using the service account email.
- Click the Save button. A message appears confirming the addition of your service account.
- View existing service account users by going to the Users tab and then clicking the Service Account filter.
Creating a Custom OAuth App
Creating a custom OAuth app is not typically necessary to follow the authentication guide (see Establishing a Connection): the provider is already registered with Google Ads Manager and you can connect with its embedded OAuth credentials. If you are making a Web application, you need to register an app. (The embedded credentials are not suitable for Web apps.) You can also create your own app to display your own information, instead of provider information, when users log into Google Ads Manager to grant permissions to the provider.
Service accounts use different OAuth credentials; you need to create an OAuth application in this OAuth flow.
Create an OAuth App for User Account Authentication
Follow the steps below to register an app to obtain the OAuthClientId, OAuthClientSecret, and callback URL:
- Log into the Google API Console and open a project. Select the API Manager from the main menu.
-
If you are connecting from a desktop application, click Credentials -> Create Credentials -> OAuth Client Id. Click Other.
If you are connecting from a Web application, click Web Application. In the Authorized Redirect URIs box, enter the URL you want to be used as a trusted redirect URL, where the user will return with the token that verifies that they have granted your app access.
After creatinghe app, the OAuthClientId and OAuthClientSecret are displayed. Follow the steps below to authorize the application; if you are a third-party developer, you may need to have your client perform these steps for you.
- Go to your DoubleClickFP for Publishers network.
- Click the Admin tab.
- Ensure that API access is enabled.
Create an OAuth App for Service Account Authentication
To obtain the necessary authentication properties in the service account flow, follow the steps below to create an OAuth application and generate a private key. You will then authorize the app.
Generate a Private Key
Follow the steps below to create a service account:
- Log into the Google API Console and open a project. Select the API Manager from the main menu.
- Click Credentials -> Create Credentials -> Service Account Key.
- In the Service Account menu, select New Service Account or select an existing service account.
- If you are creating a new service account, additionally select one or more roles. You can assign primitive roles at the project level in the IAM and Admin section; other roles enable you to further customize access to Google APIs.
- In the Key Type section, select the P12 key type.
- Download the key pair. The private key's password is displayed: Set this in OAuthJWTCertPassword.
- In the Service Account Keys section on the Credentials page, click Manage Service Accounts and set OAuthJWTIssuer to the email address displayed in the service account Id section.
Configure Your DFP Network
If you are a third-party developer, you may need to have your client do this step for you.
- Go to your DoubleClickFP for Publishers network.
- Click the Admin tab.
- Ensure that API access is enabled.
Follow the steps below to authorize the app; you are then ready to follow the authentication guide.
- Click the Add a Service Account User button.
- Fill in the form using the service account email.
- Click the Save button. A message appears confirming the addition of your service account.
- View existing service account users by going to the Users tab and then clicking the Service Account filter.
Connecting Through a Firewall or Proxy
To connect through the Windows system proxy, you do not need to set any additional connection properties. To connect to other proxies, set ProxyAutoDetect to false and in addition set the following.
To authenticate to an HTTP proxy, set ProxyAuthScheme, ProxyUser, and ProxyPassword, in addition to ProxyServer and ProxyPort.
To connect to other proxies, set FirewallType, FirewallServer, and FirewallPort. To tunnel the connection, set FirewallType to TUNNEL. To authenticate to a SOCKS proxy, set FirewallType to SOCKS5. Additionally, specify FirewallUser and FirewallPassword.
Troubleshooting the Connection
To show provider activity from query execution to network traffic, use Logfile and Verbosity. The examples of common connection errors below show how to use these properties to get more context. Contact the support team for help tracing the source of an error or circumventing a performance issue.
- Authentication errors: Typically, recording a Logfile at Verbosity 4 is necessary to get full details on an authentication error.
- Queries time out: A server that takes too long to respond will exceed the provider's client-side timeout. Often, setting the Timeout property to a higher value will avoid a connection error. Another option is to disable the timeout by setting the property to 0. Setting Verbosity to 2 will show where the time is being spent.