2. Pocket Manipulation API
• Add API
https://getpocket.com/developer/docs/v3/add
• Modify API
https://getpocket.com/developer/docs/v3/modify
• Retrieve API
https://getpocket.com/developer/docs/v3/retrieve
7. Steps:
1. Obtain request_token.
2. Login & authenticate with request_token.
3. Convert request_token into access_token.
P.S.
1. Must be done over HTTPS.
2. Must be POST method.
8. Step 1. Obtain request_token.
Use consumer_key and redirect_uri to register and
obtain a request_token.
9. Step 1. Obtain request_token.
Use consumer_key and redirect_uri to register and
obtain a request_token.
The URI to redirect
after authentication.
11. authenticate: function(callback) {
// get request token to open authentication page
this._post(
"https://getpocket.com/v3/oauth/request",
JSON.stringify({
consumer_key: this.CONSUMER_KEY,
redirect_uri: this.REDIRECT_URI
}),
response => {
this._openAuthenticationPage(response.code, callback);
}
);
}
12. Step 2. Login & authenticate with request_token.
Use requset_token to open the authentication page to
authenticate the request_token by user.
And the redirect_uri parameter to open authentication
page must be as same as the redirect_uri to register
request_token in step 1.
13. We need to open the page to
let user login and authorize.
https://getpocket.com/auth/authorize?
request_token=xxx&redirect_uri=yyy
14. We need to open the page to
let user login and authorize.
https://getpocket.com/auth/authorize?
request_token=xxx&redirect_uri=yyy
In Firefox OS, the redirect_uri can not work
with the app protocol.
15. We need to open the page to
let user login and authorize.
https://getpocket.com/auth/authorize?
request_token=xxx&redirect_uri=yyy
In Firefox OS, the redirect_uri can not work
with the app protocol.
We need to close the authentication page
after authentication.
22. Steps:
1. Obtain request_token.
2. Login with Firefox account.
3. Authenticate with request_token.
4. Convert request_token into access_token.
P.S.
1. Must be done over HTTPS.
2. Must be POST method.
23. Steps:
1. Obtain request_token.
2. Login with Firefox account.
3. Authenticate with request_token.
4. Convert request_token into access_token.
P.S.
1. Must be done over HTTPS.
2. Must be POST method.
24. Step 2. Login with Firefox account.
Log in with Firefox account. And the redirect_uri
information is missing when we redirect to the Firefox
account log-in page.
After Firefox account logged-in, we only let Firefox
account authorize Pocket to use the data in Firefox
account.
And then, this iframe will be redirected to Pocket and
should be closed.
31. _openAuthenticationPage: function(requestToken, callback) {
var authUrl = ["https://getpocket.com/auth/authorize?request_token=", requestToken, "&redirect_uri=",
this.REDIRECT_URI].join("");
var authWin = document.createElement('iframe');
authWin.setAttribute('src', authUrl);
authWin.setAttribute('mozbrowser', true);
authWin.setAttribute('class', 'fullscreen');
authWin.addEventListener('mozbrowserlocationchange', evt => {
var url = new URL(evt.detail);
if (url.protocol + '//' + url.host + url.pathname == "https://getpocket.com/a/") {
document.body.removeChild(authWin);
this._openAuthenticationPage(requestToken, callback);
}
else if (url.href == this.REDIRECT_URI) {
this._getAccessToken(requestToken, callback);
document.body.removeChild(authWin);
32. _openAuthenticationPage: function(requestToken, callback) {
var authUrl = ["https://getpocket.com/auth/authorize?request_token=", requestToken, "&redirect_uri=",
this.REDIRECT_URI].join("");
var authWin = document.createElement('iframe');
authWin.setAttribute('src', authUrl);
authWin.setAttribute('mozbrowser', true);
authWin.setAttribute('class', 'fullscreen');
authWin.addEventListener('mozbrowserlocationchange', evt => {
var url = new URL(evt.detail);
if (url.protocol + '//' + url.host + url.pathname == "https://getpocket.com/a/") {
document.body.removeChild(authWin);
this._openAuthenticationPage(requestToken, callback);
}
else if (url.href == this.REDIRECT_URI) {
this._getAccessToken(requestToken, callback);
document.body.removeChild(authWin);
After logged in
33. _openAuthenticationPage: function(requestToken, callback) {
var authUrl = ["https://getpocket.com/auth/authorize?request_token=", requestToken, "&redirect_uri=",
this.REDIRECT_URI].join("");
var authWin = document.createElement('iframe');
authWin.setAttribute('src', authUrl);
authWin.setAttribute('mozbrowser', true);
authWin.setAttribute('class', 'fullscreen');
authWin.addEventListener('mozbrowserlocationchange', evt => {
var url = new URL(evt.detail);
if (url.protocol + '//' + url.host + url.pathname == "https://getpocket.com/a/") {
document.body.removeChild(authWin);
this._openAuthenticationPage(requestToken, callback);
}
else if (url.href == this.REDIRECT_URI) {
this._getAccessToken(requestToken, callback);
document.body.removeChild(authWin);
After logged in
Authenticate again!
34. Step 3. Authenticate with request_token.
When Pocket have been authorized by Firefox account,
it means the user have already logged in Pocket.
The next step is to let Pocket authenticate the
request_token. This step is as same as the step 2 to
authenticate with Pocket account.