OAuth 1.0 クライアントライブラリ for xyzzy
-
NetInstallerをよりインストール
下記のURLのパッケージリストを登録し、パッケージ
*scrap*
よりインストールして下さい。 -
手動インストール
oauth.l を
*load-path*
に配置してください。
※依存ライブラリxml-http-requestを別途インストールしておく必要があります。
(consumer-key consumer-secret request-token-url authorize-url access-token-url) => oauth-token, oauth-token-secret
- cosumer-key - サービスプロバイダより発行されたConsumer Key
- consumer-secret - サービスプロバイダより発行されたConsumer Secret
- request-token-url - リクエストトークン発行用URL
- authorize-url -- サービスプロバイダの認証用URL
- access-token-url -- アクセストークン発行用URL
以下の一連の認証処理を実行し、取得したアクセストークン(oauth_token
, oauth_token_secret
)を多値で返します。
- リクエストトークンの要求
- 認証用ページ表示 (システム標準のWEBブラウザを起動して表示します)
- PIN (oauth_verifier) 入力
- アクセストークン取得
twitterよりアクセストークンを取得し、ファイルに保存する例
(multiple-value-bind (token token-secret)
(get-access-token *my-app-key* *my-app-secret*
"http://api.twitter.com/oauth/request_token"
"http://api.twitter.com/oauth/authorize"
"http://api.twitter.com/oauth/access_token")
(with-open-file (str *token-file* :direction :output)
(format str "~A~%~A" token token-secret)))
(credential method apiurl params) => header-string
- credential - 4つのトークン (
:consumer-key
,:consumer-secret
,:token
,:token-secret
) のplist - method - HTTPメソッド (シンボル or 文字列)
- apiurl - APIのURL
- params - APIに渡すパラメータのplist
サービスプロバイダのAPIを利用する際に必要なOAuth認証ヘッダを生成します。
twitterのhelp/test APIにリクエストを投げる例
(let* ((url "http://api.twitter.com/1/help/test.json")
(cred (list :consumer-key *my-app-key*
:consumer-secret *my-app--secret*
:token *token*
:token-secret *token-secret*))
(auth (oauth:auth-header cred 'get url nil)))
(xhr:xhr-get url :headers `(:Authorization ,auth)
:key #'xhr:xhr-response-text))
Yousuke Ushiki (citrus.yubeshi@gmail.com)
MIT License を適用しています。