pocket-auth
A small node.js library for authenticating with the Pocket API.
pocket-auth
requires a minimum NodeJS version of 7.6
The Pocket Auth Flow
Pocket use a modified oauth
flow for gaining an access token that looks like the following:
- Fetch a
request_token
by making aPOST
request to https://getpocket.com/v3/oauth/request - Open a browser to https://getpocket.com/auth/authorize?request_token={request_token}&redirect_uri={redirect_uri}, where
redirect_uri
the the URL to redirect to afterwards.- In a normal OAuth flow, the URL will contain an access token as a
GET
parameter at this point - In Pocket's flow, they redirect to
redirect_uri
exactly as it is provided. They do not add an access token (you request that separately later) - This means that you can use
https://google.com
as your redirect URL
- In a normal OAuth flow, the URL will contain an access token as a
- Once the user has clicked
Approve
, you can exchange yourrequest_token
for an access token by making aPOST
request to https://getpocket.com/v3/oauth/authorize
Example Usage
You can use this library with either a Promise or a Callback based interface
async/await
{ try var auth = ; var consumerKey = "your-consumer-key"; var redirectUri = "https://google.com"; let code = await auth; let uri = auth; console; console; ; catch err console; } ;
Callback
var auth = ; var consumerKey = "your-consumer-key";var redirectUri = "https://google.com"; auth;