Skip to content

youz/xl-oauth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

xl-oauth

OAuth 1.0 クライアントライブラリ for xyzzy

Install

  • NetInstallerをよりインストール

    下記のURLのパッケージリストを登録し、パッケージ*scrap*よりインストールして下さい。

    http://youz.github.io/xyzzy/packages.l

  • 手動インストール

    oauth.l を*load-path*に配置してください。

※依存ライブラリxml-http-requestを別途インストールしておく必要があります。

Usage

function oauth:get-access-token

(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)を多値で返します。

  1. リクエストトークンの要求
  2. 認証用ページ表示 (システム標準のWEBブラウザを起動して表示します)
  3. PIN (oauth_verifier) 入力
  4. アクセストークン取得

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)))

function oauth:auth-header

(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))

Author

Yousuke Ushiki (citrus.yubeshi@gmail.com)

@Yubeshi

Copyright

MIT License を適用しています。

About

OAuth 1.0 library for xyzzy

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published