npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dfp-wrapper

v1.4.0

Published

Simplifies and promisifies calls to node-google-dfp.

Downloads

1

Readme

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.

{
 "networkCode": "<network code>",
 "appName": "<Name of your app>",
 "version": "<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.

Obtain refresh token

  1. Run:
$ cd node_modules/node-google-dfp-wrapper/
$ node generate-authentication-url.js

Go to the url and give authorization. Copy the auth code.

  1. 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

  1. Log into Google.
  2. Go to https://console.developers.google.com/project.
  3. Make a project for your app.
  4. Go to <https://console.developers.google.com/apis/credentials?project=.
  5. Click on New Credentials and then on OAuth client ID
  6. Click on Configure consent screen and give your project a name.
  7. Under Application type select Other and give your client a name.
  8. 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 as local/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"
    ]
  }
}