getpocket

nodejs for Pocket

nodejs for Pocket

nodejs for Pocket

First, install the pocket sdk with npm.

npm install getpocket
  • constructor: (consumer_key, redirect_uri) ->
  • authorizeRoute: (req, res) ->
  • authorize: (callback) ->
  • getAccessToken: (code, callback) ->
  • Pocket.getPocket(options, callback)
  config = {
    consumer_key: 'your consumer_key'
    redirect_uri: 'http://example.com/pocket/callback'
  }
 
  pocket = require('getpocket').getPocket(config)`
or
  Pocket = require('getpocket')
  pocket = new Pocket('consumer_key', 'redirect_uri')
  # res redirect to pocket auth
  app.get('/pocket/authorize', (req, res) -> pocket.authorizeRoute(req, res))
 
  app.get('/pocket/callback', (req,res) ->
    pocket.getAccessToken(req.query.code, (err, r) ->
        # r: { access_token: '', username: ''}
        res.json(r)
    )
  )