{"id":15529818,"url":"https://github.com/mheap/pocket-auth","last_synced_at":"2025-04-23T12:56:21.302Z","repository":{"id":40708054,"uuid":"108034805","full_name":"mheap/pocket-auth","owner":"mheap","description":null,"archived":false,"fork":false,"pushed_at":"2024-06-16T15:29:51.000Z","size":475,"stargazers_count":10,"open_issues_count":8,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-24T14:14:04.543Z","etag":null,"topics":["api","authentication","getpocket","nodejs","pocket"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mheap.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-23T20:19:54.000Z","updated_at":"2024-05-12T23:46:23.000Z","dependencies_parsed_at":"2023-02-06T06:16:50.254Z","dependency_job_id":null,"html_url":"https://github.com/mheap/pocket-auth","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mheap%2Fpocket-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mheap%2Fpocket-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mheap%2Fpocket-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mheap%2Fpocket-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mheap","download_url":"https://codeload.github.com/mheap/pocket-auth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242052662,"owners_count":20064226,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","authentication","getpocket","nodejs","pocket"],"created_at":"2024-10-02T11:20:01.503Z","updated_at":"2025-03-05T15:30:46.635Z","avatar_url":"https://github.com/mheap.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pocket-auth\n\nA small node.js library for authenticating with the [Pocket](https://getpocket.com) API.\n\n`pocket-auth` requires a minimum NodeJS version of 6.0\n\n## The Pocket Auth Flow\n\nPocket use a modified `oauth` flow for gaining an access token that looks like the following:\n\n* Fetch a `request_token` by making a `POST` request to https://getpocket.com/v3/oauth/request\n* Open a browser to https://getpocket.com/auth/authorize?request_token={request_token}\u0026redirect_uri={redirect_uri}, where `redirect_uri` the the URL to redirect to afterwards.\n    * In a normal OAuth flow, the URL will contain an access token as a `GET` parameter at this point\n    * 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)\n    * This means that you can use `https://google.com` as your redirect URL\n* Once the user has clicked `Approve`, you can exchange your `request_token` for an access token by making a `POST` request to https://getpocket.com/v3/oauth/authorize\n\n## Example Usage\n\nYou can use this library with either a Promise or a Callback based interface\n\n### async/await\n\n```javascript\nasync function main() {\n    try {\n        var auth = require(\"pocket-auth\");\n\n        var consumerKey = \"your-consumer-key\";\n        var redirectUri = \"https://google.com\";\n\n        let code = await auth.fetchToken(consumerKey, redirectUri, {});\n        let uri = auth.getRedirectUrl(code.code, redirectUri);\n        console.log(\"Visit the following URL and click approve in the next 10 seconds:\");\n        console.log(uri);\n\n        setTimeout(async function(){\n            try {\n                let r = await auth.getAccessToken(consumerKey, code.code);\n                console.log(r);\n            } catch (err) {\n                console.log(\"You didn't click the link and approve the application in time\");\n            }\n        }, 10000);\n    } catch (err) {\n        console.log(err);\n    }\n}\n\nmain();\n```\n\n### Callback\n\n```javascript\nvar auth = require(\"pocket-auth\");\n\nvar consumerKey = \"your-consumer-key\";\nvar redirectUri = \"https://google.com\";\n\nauth.fetchToken(consumerKey, redirectUri, {}, function(err, code) {\n    let uri = auth.getRedirectUrl(code.code, redirectUri);\n    console.log(\"Visit the following URL and click approve in the next 10 seconds:\");\n    console.log(uri);\n\n    setTimeout(async function(){\n        auth.getAccessToken(consumerKey, code.code, function(err, r) {\n            if (err) {\n                console.log(\"You didn't click the link and approve the application in time\");\n                return;\n            }\n\n            console.log(r);\n        });\n    }, 10000);\n});\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmheap%2Fpocket-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmheap%2Fpocket-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmheap%2Fpocket-auth/lists"}