Skip to content

Commit 6ff910a

Browse files
Update README.md (#16548)
1 parent e7d1f17 commit 6ff910a

File tree

1 file changed

+79
-4
lines changed

1 file changed

+79
-4
lines changed

components/google_ads/README.md

Lines changed: 79 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ such as creating and managing campaigns, adding and removing keywords, and
1919
adjusting bids. You can also use the API to get information about your
2020
campaigns, such as campaign stats, keyword stats, and ad performance.
2121

22-
## Customizing API requests with the Pipedream proxy
22+
## Customizing API requests from within the Pipedream workflow builder
2323

24-
The Pipedream components interact with Google Ads API through Pipedream's proxy service, which handles authentication and developer token requirements.
24+
The Pipedream components interact with Google Ads API through an interal proxy service, which protects Pipedream's developer token.
2525

2626
The component accepts a standard Google Ads API request object with the following structure:
2727

2828
```javascript
2929
const googleAdsReq = {
3030
method: "get|post|put|delete", // HTTP method
31-
url: "/v16/...", // Google Ads API endpoint path
31+
url: "/v18/...", // Google Ads API endpoint path
3232
headers: {
3333
Authorization: `Bearer ${this.googleAds.$auth.oauth_access_token}`,
3434
},
@@ -58,4 +58,79 @@ const googleAdsReq = {
5858
};
5959
```
6060

61-
The proxy endpoint will remain the same: `https://googleads.m.pipedream.net`
61+
**The proxy endpoint will remain the same: `https://googleads.m.pipedream.net`**
62+
63+
## Using Google Ads with the Connect API Proxy
64+
65+
To interface with Google Ads via the [Connect API Proxy](https://pipedream.com/docs/connect/api-proxy), you essentially need to nest the request like this:
66+
67+
**Important notes:**
68+
69+
- The upstream URL in this case is Pipedream's proxy service for Google Ads
70+
- Like in the [above examples](#customizing-api-requests-from-within-the-pipedream-workflow-builder), you'll define the Google Ads URL with the `url` param in the `body`
71+
- The `method` to the Connect Proxy should always be a `POST`, since it's actually targeting the Google Ads proxy (define the method for the Google Ads request in `options.body.method`)
72+
73+
### Using the Pipedream SDK
74+
75+
```javascript
76+
const pd = createBackendClient({
77+
apiHost: process.env.API_HOST,
78+
credentials: {
79+
clientId: process.env.CLIENT_ID,
80+
clientSecret: process.env.CLIENT_SECRET,
81+
},
82+
environment: process.env.ENVIRONMENT,
83+
projectId: process.env.PROJECT_ID,
84+
});
85+
86+
const pdGoogleAdsUrl = "https://googleads.m.pipedream.net";
87+
88+
const resp = await pd.makeProxyRequest(
89+
{
90+
searchParams: {
91+
external_user_id: process.env.EXTERNAL_USER_ID,
92+
account_id: process.env.ACCOUNT_ID,
93+
},
94+
},
95+
{
96+
url: pdGoogleAdsUrl,
97+
options: {
98+
method: "POST",
99+
body: {
100+
url: "/v19/customers:listAccessibleCustomers",
101+
method: "GET",
102+
// data: {} // If you need to send a body with a POST request, define it here
103+
},
104+
},
105+
}
106+
);
107+
```
108+
109+
### Using the Connect REST API
110+
111+
```bash
112+
# First, obtain an OAuth access token to authenticate to the Pipedream API
113+
114+
curl -X POST https://api.pipedream.com/v1/oauth/token \
115+
-H "Content-Type: application/json" \
116+
-d '{
117+
"grant_type": "client_credentials",
118+
"client_id": "{your_oauth_client_id}",
119+
"client_secret": "{your_oauth_client_secret}"
120+
}'
121+
122+
# The response will include an access_token. Use it in the Authorization header below.
123+
124+
# Base64 encode the Pipedream endpoint for Google Ads: https://googleads.m.pipedream.net
125+
126+
curl -X POST "https://api.pipedream.com/v1/connect/{your_project_id}/proxy/{url_safe_base64_encoded_url}?external_user_id={external_user_id}&account_id={apn_xxxxxxx}" \
127+
-H "Authorization: Bearer {access_token}" \
128+
-H "x-pd-environment: {development | production}" \
129+
-d '{
130+
"url": "/v19/customers:listAccessibleCustomers",
131+
"method": "GET",
132+
# "data": {} # If you need to send a body with a POST request, define it here
133+
}'
134+
135+
# Parse and return the data you need
136+
```

0 commit comments

Comments
 (0)