0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Pocket API】認証をワンライナーで実施する

0
Last updated at Posted at 2024-04-22

PocketのAPIを使いたいけれど、OAuthの認証フローが面倒だと感じたことはありませんか?

この記事では、npx または deno run のワンライナーでPocketのアクセストークンを取得する方法を紹介します。コンシューマキーさえあれば、ツールのインストール不要でトークンを取得できます。

前提条件

コンシューマキーを事前に取得しておく必要があります。下記公式ドキュメントの Step 1 をブラウザで実施してください。

Pocket Authentication API Documentation

Node.jsで取得する

  1. 下記コマンドをターミナルで実行します

    npx pocket-auth <consumer_key>
    
  2. デフォルトブラウザでPocketのURLが開くのでログインします

  3. 「こんにちは! ユーザ名があなたの Pocket アカウントへの接続を求めています」というメッセージの下の認可ボタンを押します

Denoで取得する

  1. 下記コマンドをターミナルで実行します

    deno run --allow-env --allow-net --allow-sys --allow-read --allow-run npm:pocket-auth-cli <consumer_key>
    
  2. デフォルトブラウザでPocketのURLが開くのでログインします

  3. 「こんにちは! ユーザ名があなたの Pocket アカウントへの接続を求めています」というメッセージの下の認可ボタンを押します

まとめ

  • Pocketのアクセストークンは npx pocket-auth または deno run npm:pocket-auth-cli で取得できる
  • いずれもツールの事前インストール不要
  • コンシューマキーの取得のみ事前にブラウザで実施が必要
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?