rubicon-project/node-google-dfp
Fork: 35 Star: 85 (更新于 1970-01-01 00:00:00)
license: ISC
Language: JavaScript .
A service for integrating with Google DFP over NodeJS
最后发布版本: 0.3.2 ( 2018-04-03 19:27:17)
Google DFP API Client for NodeJS
Basics
Initialize the DFP Instance.
var Dfp = require('node-google-dfp'),
dfpUser = new Dfp.User(NETWORK_CODE, APP_NAME, VERSION);
Next, setup your client settings and your user's OAUTH token information.
dfpUser.setSettings({
client_id : "YOUR CLIENT ID",
client_secret : "YOUR CLIENT SECRET",
refresh_token : "A REFRESH TOKEN",
redirect_url : "YOUR OAUTH REDIRECT URL"
});
You can instance any of DFP's API Services; https://developers.google.com/doubleclick-publishers/docs/start
dfpUser.getService('LineItemService', function (err, lineItemService) {
if (err) {
return console.error(err);
}
var statement = new DfpClass.Statement('WHERE id = 103207340');
lineItemService.getLineItemsByStatement(statement, function (err, results) {
console.log(results);
});
});
Service accounts example
If you would like to use a Google Service Account to access DFP, you can do so by creating an instance of the JWT auth client.
var {JWT} = require('google-auth-library')
var jwtClient = new JWT(
SERVICE_ACCOUNT_EMAIL,
'path/to/key.pem',
null,
['https://www.googleapis.com/auth/dfp']);
dfpUser.setClient(jwtClient)
=======
oAuth setup
This application requires a working oAuth refresh token to make requests. If you don't include a refresh token you will get an "No refresh token is set" error. If you include a bad token, you'll get an "illegal access" error. Service accounts are not supported.
To setup a refresh token manually, follow Google's instructions for using cURL. The main steps are included below.
-
Setup a oAuth "installed application" in the Google Developer Console.
-
Create a verification request using this installed application's client ID. (If you miss this step you'll get an
authorization_pending
error from Google on the next step.) Note that any slashes in adevice_code
will need to be escaped.
curl -d "client_id={YOUR_OAUTH_CLIENT_ID}&scope=https://www.googleapis.com/auth/dfp" https://accounts.google.com/o/oauth2/device/code
{
"device_code" : "ABCD-EFGH4/MEiMYvOO1THXLV_fHGGN8obAgb5XFs1Uctj-QsyYsQk",
"user_code" : "ABCD-EFGH",
"verification_url" : "https://www.google.com/device",
"expires_in" : 1800,
"interval" : 5
}
-
Visit the
verification_url
contained in the verification request response (e.g. https://www.google.com/device) in a browser and type in theuser_code
provided in the verification response. A verification code will be given as a response. -
Use the provided
code
and your client ID and secret from the Google oAuth application to create a refresh token.
curl -d "client_id={YOUR_OAUTH_CLIENT_ID}&client_secret={YOUR_OAUTH_CLIENT_SECRET}&code={YOUR_VERIFICATION_CODE}&grant_type=http://oauth.net/grant_type/device/1.0" https://accounts.google.com/o/oauth2/token
{
"access_token" : "ya29.JAHynQpVpjBFhvg-7VKdQ7nmD0DkmCYoWTWo535TP8QsKa6j2rFOI1i0pdclFepv_GZo9A2SrN41dA",
"token_type" : "Bearer",
"expires_in" : 3600,
"id_token" : "eyJhbGciOiJSUzI1NiIsImtpZCI6IjdjZmM3YTJhMDkwYWJjOGYxMDU5MjJmMzFiN2FjZGUzYzA2NmU1NTYifQ.eyJpc3MiOiJhY2NvdW50cy5nb29nbGUuY29tIiwiaWQiOiIxMTU2MjQxNzA0MjQ3NzA5NDYzNzgiLCJzdWIiOiIxMTU2MjQxNzA0MjQ3NzA5NDYzNzgiLCJhenAiOiI4MzQ3MDQ2OTI1ODItMzlwY3I2M2RmNjBlZjByY2E5ZTc1cDRicTlzbjhxOWUuYXBwcy5nb29nbyV1c2VyY29udGVudC5jb20iLCJlbWFpbCI6InRheWxvci5idWxleUBtY25hdWdodG9uLm1lZGlhIiwiYXRfaGFzaCI6Ikp2Sl9JUDlxUk9zX1JUNDBoY0FSWVEiLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiYXVkIjoiODM0NzA0HjkyNTgyLTM5cGNyNjNkZjYwZWYwcmNhOWU3NXA0YnE5c244cTllLmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwiaGQiOiJtY25hdWdodG9uLm1lZGlhIiwidG9rZW5faGFzaCI6Ikp2Sl9JSDlxUk9zX1JUNDBoY0FSWVEiLCJ2ZXJpZmllZF9lbWFpbCI6dHJ1ZSwiY2lkIjoiODM0NzA0NjkyNTgyLTM5cGNyNjNkZjYwZWYwcmNhOWU3NXA0YnE5c244cTllLmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwiaWF0IjoxNDI0ODAwNDcwLCJleHAiOjE0MjQ4MDQzNzB9.T9mTcSl5bJLKrFhldXOd1L1CnGFfZHNF1eQOmJYyp7wR3vKbz8ATTNAfyo8_2hSGt9kGrHDBcdgaq_18RYS72Tt0MclNy020romjl6rYRjs6GH93S3ZMiwra3UI3kmDXym9kyntedMS5gIPgJWfcoh0J0CTDNPBisLNrZntJv7Y",
"refresh_token" : "1/CGpCHgTgJ28PMnh84PgQBOgHHHaLCDbDQ_0ZiINmO_g"
}
You can use urn:ietf:wg:oauth:2.0:oob
for the redirect URL of non-public apps.
Known Issues
- OAuth Support for more than just Refresh Token
- No unit tests
How to contribute
Follow Github's recommended workflow for contributing to this project.
- Fork it
- Create your feature branch (
git checkout -b your-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin your-new-feature
) - Create new Pull Request
最近版本更新:(数据更新于 1970-01-01 00:00:00)
2018-04-03 19:27:17 0.3.2
2016-04-08 22:28:31 0.2.2
2016-01-12 04:53:21 0.2.1
2015-08-21 22:06:12 0.2.0
2015-07-30 08:52:03 v0.2.0
2015-07-13 05:40:23 0.1.7
2014-10-09 02:54:46 0.1.5
2014-10-09 02:41:10 0.1.4
2014-10-09 02:38:40 0.0.1
主题(topics):
api, dfp, google, javascript, nodejs
rubicon-project/node-google-dfp同语言 JavaScript最近更新仓库
2024-12-22 13:19:55 gethomepage/homepage
2024-12-22 11:34:40 chris81605/Degrees-of-Lewdity_Cheat_Extended
2024-12-22 00:44:14 gorhill/uBlock
2024-12-21 12:14:02 layui/layui
2024-12-21 03:44:01 emberjs/ember.js
2024-12-20 02:57:09 nodejs/node