var DfpClass = require('./lib/Dfp');var dfpUser = new DfpClass.User('YOUR NETWORK CODE', 'YOUR APP NAME');dfpUser.setSettings({client_id: "YOUR CLIENT ID",client_secret: "YOUR CLIENT SECRET",refresh_token: "REFRESH TOKEN",redirect_url: "YOUR REDIRECT URL"});dfpUser.getService('InventoryService', function (inventoryService) {var args = new DfpClass.Statement('LIMIT 100');inventoryService.getAdUnitSizesByStatement(args, function (err, results) {if (err) {console.log(err.response.body);return;}console.log(results.rval);});});
Rene
You need to create/register an app on the Google Cloud Console
Here are the basic instructions: https://developers.google.com/accounts/docs/OAuth2#basicsteps
Regarding role-based access, I don’t think that is available from API. So your entire app will use same client_secret/client_key
Hope this helps you out.
Thanks,
Aaron
--
You received this message because you are subscribed to a topic in the Google Groups "Google's DoubleClick for Publishers API Forum" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/google-doubleclick-for-publishers-api/3xwCg6UohMo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
google-doubleclick-for-p...@googlegroups.com.
To post to this group, send email to
google-doubleclick...@googlegroups.com.
Visit this group at
http://groups.google.com/group/google-doubleclick-for-publishers-api.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and all its topics, send an email to google-doubleclick-for-publishers-api+unsubscribe@googlegroups.com.
To post to this group, send email to google-doubleclick-for-publishers-api@googlegroups.com.
POST /o/oauth2/token HTTP/1.1
Host: accounts.google.com
Content-Type: application/x-www-form-urlencoded
code=#code#&client_id=#clientId#&client_secret=#clientSecret#&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&grant_type=authorization_code
{ "error": "invalid_request", "error_description": "Required parameter is missing: grant_type"}Rene
Looks like you passed a grant_type in your request, not sure why it failed.
The following worked fine for me :
curl --data "grant_type=authorization_code&client_id=REDACTED&client_secret=REDACTED&code=REDACTED" https://accounts.google.com/o/oauth2/token
Once you get this refresh token, you can continually refresh using that, by using the `googleapis` node.js module like so:
var OAuth2 = require('googleapis').auth.OAuth2;
var OAuthClient = new OAuth2(client_id, client_secret, redirect_url);
OAuthClient.credentials = { refresh_token: refresh_token };
OAuthClient.refreshAccessToken(function(token){
// token arg passed to callback will have properties ‘access_token’, ‘token_type’, ‘expires_in’, and ‘refresh_token’
});
Hope this helps you out!!!
Thanks,
Aaron
From: google-doubleclick...@googlegroups.com [mailto:google-doubleclick...@googlegroups.com]
On Behalf Of Vincent Tsao (DFP API Team)
Sent: Thursday, October 16, 2014 12:17 PM
To: google-doubleclick...@googlegroups.com
Cc: rene.si...@gmail.com
Subject: Re: Google DFP Client for Node.JS
You need to pass in a grant_type, please see the documentation here:
To unsubscribe from this group and all its topics, send an email to
google-doubleclick-for-p...@googlegroups.com.
To post to this group, send email to
google-doubleclick...@googlegroups.com.
Visit this group at
http://groups.google.com/group/google-doubleclick-for-publishers-api.
For more options, visit
https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "Google's DoubleClick for Publishers API Forum" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/google-doubleclick-for-publishers-api/3xwCg6UohMo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
google-doubleclick-for-p...@googlegroups.com.
To post to this group, send email to
google-doubleclick...@googlegroups.com.
To unsubscribe from this group and all its topics, send an email to google-doubleclick-for-publishers-api+unsubscribe@googlegroups.com.
To post to this group, send email to google-doubleclick-for-publishers-api@googlegroups.com.
Visit this group at http://groups.google.com/group/google-doubleclick-for-publishers-api.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "Google's DoubleClick for Publishers API Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-doubleclick-for-publishers-api/3xwCg6UohMo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-doubleclick-for-publishers-api+unsubscribe@googlegroups.com.
To post to this group, send email to google-doubleclick-for-publishers-api@googlegroups.com.
Rene
I used same redirect_uri in my request(sorry, cut and paste error) and it worked. So the only thing I can think of is maybe check the app settings in the console, you should see that same exact string listed under “redirect uris”.
Thanks
Aaron
From: google-doubleclick...@googlegroups.com [mailto:google-doubleclick...@googlegroups.com]
On Behalf Of René Simon
Sent: Friday, October 17, 2014 12:49 AM
To: google-doubleclick...@googlegroups.com
Cc: dfpapi-advi...@google.com; rene.si...@gmail.com
Subject: Re: Google DFP Client for Node.JS
Thanks Aaron, that was the a next step.
To unsubscribe from this group and all its topics, send an email to
google-doubleclick-for-p...@googlegroups.com.
To post to this group, send email to google-doubleclick...@googlegroups.com.
Visit this group at
http://groups.google.com/group/google-doubleclick-for-publishers-api.
For more options, visit
https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "Google's DoubleClick for Publishers API Forum" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/google-doubleclick-for-publishers-api/3xwCg6UohMo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
google-doubleclick-for-p...@googlegroups.com.
To post to this group, send email to google-doubleclick...@googlegroups.com.
Visit this group at
http://groups.google.com/group/google-doubleclick-for-publishers-api.
For more options, visit
https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "Google's DoubleClick for Publishers API Forum" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/google-doubleclick-for-publishers-api/3xwCg6UohMo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
google-doubleclick-for-p...@googlegroups.com.
To post to this group, send email to
google-doubleclick...@googlegroups.com.

{ "error" : "invalid_grant"}Rene
I used same redirect_uri in my request(sorry, cut and paste error) and it worked. So the only thing I can think of is maybe check the app settings in the console, you should see that same exact string listed under “redirect uris”.
To unsubscribe from this group and all its topics, send an email to google-doubleclick-for-publishers-api+unsubscribe@googlegroups.com.
To post to this group, send email to google-doubleclick-for-publishers-api@googlegroups.com.
Visit this group at http://groups.google.com/group/google-doubleclick-for-publishers-api.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "Google's DoubleClick for Publishers API Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-doubleclick-for-publishers-api/3xwCg6UohMo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-doubleclick-for-publishers-api+unsubscribe@googlegroups.com.
To post to this group, send email to google-doubleclick-for-publishers-api@googlegroups.com.
Visit this group at http://groups.google.com/group/google-doubleclick-for-publishers-api.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "Google's DoubleClick for Publishers API Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-doubleclick-for-publishers-api/3xwCg6UohMo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-doubleclick-for-publishers-api+unsubscribe@googlegroups.com.
To post to this group, send email to google-doubleclick-for-publishers-api@googlegroups.com.
Visit this group at http://groups.google.com/group/google-doubleclick-for-publishers-api.
For more options, visit https://groups
...
var google = require('googleapis');
var OAuth2 = google.auth.OAuth2;
var url = oauth2Client.generateAuthUrl({
access_type: 'offline',
scope: ['https://www.googleapis.com/auth/dfp']
});
console.log(url);tvar google = require('googleapis');
var OAuth2 = google.auth.OAuth2;
var oauth2Client = new OAuth2('{clientId}', '{clientSecret}', '{redirectUri}');
oauth2Client.getToken('{CODE}', function(error, tokens) {
if (error) {
console.error(error);
} else {
console.log(tokens);
}
});
You can. Create the request body like this:
{
attributes:
{
"xsi:type": "nameOfTheAction"
},
filterStatement: "filter statement here..."
}
One trick you can use in this type of situation, is make same request using officially supported DFP client, and turn on debugging, you can see the XML that official client creates and structure your JSON same way.
Thanks,
Aaron
{
customTargetingValueAction: {
attributes : { 'xsi:type': 'DeleteCustomTargetingValues' }
},
filterStatement: {
query: 'WHERE customTargetingKeyId = \'' + keyId + '\' AND name IN (\'' + valueNames.join('\',\'') + '\')'
}
}You can. Create the request body like this:
{
attributes:
{
"xsi:type": "nameOfTheAction"
},
filterStatement: "filter statement here..."
}
One trick you can use in this type of situation, is make same request using officially supported DFP client, and turn on debugging, you can see the XML that official client creates and structure your JSON same way.
Thanks,
Aaron
Sent: Tuesday, May 05, 2015 2:01 AM
Subject: Re: Google DFP Client for Node.JS
I'm trying to use the CustomTargetingService service action: performCustomTargetingValueAction, but I can't find a way to handle the abstract customTargetingValueAction.--
There I must set the xsi:type to DeleteCustomTargetingValues somehow.
Can someone help me with this or is it not possible to handle abstract elements?
On Wednesday, May 21, 2014 at 3:13:07 AM UTC+2, Roy Pereira wrote:We just made public a GitHub repo for a Node.JS DFP client at https://github.com/ShinyAds/node-google-dfp.
You can install is by running "npm install node-google-dfp".
This node.JS client leverages Google's 'googleapis' node.JS client for OAUTH and leverage's DFP's Soap schema heavily, so it should be future-proof.
Let us know what you think and please help making it better by contributing.
You received this message because you are subscribed to a topic in the Google Groups "Google's DoubleClick for Publishers API Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-doubleclick-for-publishers-api/3xwCg6UohMo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-doubleclick-for-publishers-api+unsubscribe@googlegroups.com.
To post to this group, send email to google-doubleclick-for-publishers-api@googlegroups.com.