|
const request = require('request'); |
|
const clientOAuth2 = require('client-oauth2'); |
|
const repl = require("repl"); |
|
const secrets = require("./secrets"); |
|
|
|
/* |
|
// https://www.npmjs.com/package/client-oauth2 |
|
const pinterestAuth = new ClientOAuth2({ |
|
clientId: '5025677251421710256', |
|
clientSecret: secrets.pinterest.client_secret, |
|
accessTokenUri: 'https://api.pinterest.com/v1/oauth/token', |
|
authorizationUri: 'https://api.pinterest.com/oauth/', |
|
redirectUri: 'https://localhost', |
|
scopes: ['read_public', 'write_public', 'read_relationships', 'write_relationships'] |
|
}) |
|
const token = pinterestAuth.createToken(secrets.pinterest.access_token); |
|
*/ |
|
|
|
// https://developers.pinterest.com/docs/api/overview/ (Use Postman to get an access token) |
|
// access token: secrets.pinterest.access_token |
|
// token type: bearer |
|
// scope: ["read_public","write_public","read_private","write_private","read_relationships","write_relationships","read_write_all"] |
|
|
|
// some useful content to read: |
|
// https://api.pinterest.com/v1/me/ |
|
// https://api.pinterest.com/v1/boards/maryannrizzo/builder-developer-projects/ |
|
// https://api.pinterest.com/v1/boards/maryannrizzo/builder-developer-projects/pins/ |
|
// https://www.pinterest.com/keifukus |
|
// https://www.pinterest.com/digifireblast |
|
|
|
const options = { |
|
url: 'https://api.pinterest.com/v1/boards/maryannrizzo/builder-developer-projects/pins/', |
|
qs: { access_token: secrets.pinterest.access_token }, |
|
headers: { 'User-Agent': 'nodejs/requests'} |
|
} |
|
|
|
request(options, (err, res, body) => { |
|
if (err) { return console.log(err); } |
|
|
|
j = JSON.parse(body); |
|
// https://stackoverflow.com/a/8549188/198348 |
|
var r = repl.start("node> "); |
|
r.context.body = body; |
|
r.context.j = j; |
|
console.log(j); |
|
|
|
}); |