nanek/node-google-dfp-wrapper
Fork: 10 Star: 16 (更新于 2024-12-11 23:19:19)
license: MIT
Language: JavaScript .
A wrapper to simplify calls to node-google-dfp and the DFP api
最后发布版本: v1.4.0 ( 2017-06-05 23:51:10)
node-google-dfp-wrapper
This project is a wrapper around node-google-dfp aimed at facilitating repeated interactions with the DFP API in a script.
Getting started
$ npm install node-google-dfp-wrapper
var Dfp = require('node-google-dfp-wrapper');
// These are created by you in the configuration step
var config = require('../local/config')
// These are output by DFP as part of the DFP project authorization step.
var credentials = require('../local/application-creds');
// This is obtained as part of the obtain refresh token step
var refreshToken = config.refreshToken;
var dfp = new Dfp(credentials, config, refreshToken);
How to use
For examples of how to use this library, please refer to https://github.com/spanishdict/example-dfp-line-item-generator
One-time setup
Configuration
These values are created by you, except for refreshToken
. If you do not have one, follow the directions below. Save the file as local/config.json
.
{
"networkCode": "<network code>",
"appName": "<Name of your app>",
"version": "<dfp api version number>",
"refreshToken": "<refresh token>"
}
To obtain your network code from DFP. It can be found in your url after you log in to DFP. For example in https://www.google.com/dfp/1027916#delivery
, the network code is 1027916.
version
is DFP API version. For example v201508
.
Obtain refresh token
-
Prepare DFP project authorization (
local/application-creds.json
). If you do not have one, follow the directions below. -
Run:
$ cd node_modules/node-google-dfp-wrapper/
$ node generate-authentication-url.js
Go to the url and give authorization. Copy the auth code.
- Run the script in "auth code" mode:
$ node generate-refresh-token.js --authCode <auth code>
If you are using this package as a dependency and local/application-creds lives in your project you can pass the config path as an arguments as follow:
$ node node_modules/node-google-dfp-wrapper/generate-authentication-url.js --config $(pwd)'/local/application-creds'
$ node node_modules/node-google-dfp-wrapper/generate-refresh-token.js --config $(pwd)'/local/application-creds' --authCode <auth code>
This will output a refresh token.
DFP project authorization
- Log into Google.
- Go to https://console.developers.google.com/project.
- Make a project for your app.
- Go to <https://console.developers.google.com/apis/credentials?project=
. - Click on
New Credentials
and then onOAuth client ID
- Click on
Configure consent screen
and give your project a name. - Under
Application type
selectOther
and give your client a name. - You should now see a new entry under
OAuth 2.0 client IDs
and a download icon to the far right. Click that icon to download your cerdentials. Save the file aslocal/application-creds.json
. It should look like this, (though you may have to format it):
{
"installed": {
"client_id": "<client id>",
"project_id": "<project id>",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_secret": "<client secret>",
"redirect_uris": [
"urn:ietf:wg:oauth:2.0:oob",
"oob"
]
}
}
最近版本更新:(数据更新于 2024-08-28 00:59:15)
2017-06-05 23:51:10 v1.4.0
2016-02-20 03:42:18 v1.3.0
2016-01-21 05:30:02 v1.2.1
nanek/node-google-dfp-wrapper同语言 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