twitter,FriendFeedのOAuth実装について

http://assets0.twitter.com/images/twitter_logo_header.png
http://friendfeed.com/static/images/nano-logo.png

■ 目的

twitterベースなマフィアゲームのおかげで一気に話題になったOAuth。
ここまできたら、みなさんにもっと詳しく知ってもらいたいということで、以下2つのサービスが実装したOAuthの仕様を見直してみます。

以下、OAuthをいくつかのステップに分けて仕様を見ていきます。

■ Consumer登録

必要な情報

twitter

  • Application Icon
  • Application Name
  • Description
  • Application Website
  • Organization
  • Website
  • Application Type
  • Callback URL
  • Default Access type : ★Scope
  • Use Twitter for login

FriendFeed

  • Application name
  • Application web site
  • Application type
  • OAuth Callback URL : 戻り先URL(Browser Appの場合)
  • Feedback group : ★ConsumerアプリへのFeedBack用のグループ

Feedback Groupは面白いですね。
しかし、Scopeの概念がないのか?

■ ConsumerKey/Signatureの仕様

twitter,FriendFeed両方とも同じ仕様。

  • ConsumerKey/SecretはSPが決めたEncrypt or Hashされたっぽい文字列
  • RSA公開鍵を登録するしくみもないので、SignatureはHMAC-SHA1

■ OAuth Core 1.0関連

twitter

Clientアプリのほうで以下のような説明文がある。

Desktop Clients

The traditional OAuth flow for desktop clients can be cumbersome. We've created a PIN-based experience for destkop clients that use the following flow:

1. The application uses oauth/request_token to obtain a request token from twitter.com.
2. The application directs the user to oauth/authorize on twitter.com.
3. After obtaining approval from the user, a prompt on twitter.com will display a 7 digit PIN.
4. The user is instructed to copy this PIN and return to the appliction.
5. The application will prompt the user to enter the PIN from step 4.
6. The application uses the PIN as the value for the oauth_verifier parameter in a call to oauth/access_token which will verify the PIN and exchange a request_token for an access_token.
7. Twitter will return an access_token for the application to generate subsequent OAuth signatures.

http://apiwiki.twitter.com/Authentication

結果的には、「RevisionAに微妙に対応」ってとこでしょうか。

FriendFeed

1. Register your application with FriendFeed to get a Consumer Key and Consumer Secret.
At the time of registration, you will also specify a Callback URL (the URL we redirect users to after authorization).
We do not support the oauth_callback parameter for security reasons.

http://friendfeed.com/api/documentation#authentication

両方とも、あらかじめcallback_urlを1つに指定しているので、書き換えられてなんとかかんとかされることはない。
ブラウザアプリの場合はRequest Token取得時に指定する必要がないようだ。

FriendFeedにはRevisionA,oobなどの記述がないので対応していないっぽいです。

■ Login/Concent Page

キャプチャをはっつけました。

twitter(未ログイン)

twitter(ログイン済み)

twitterに関しては説明省略します。

FriendFeed(未ログイン)

未ログイン状態のときにはちょっと説明のあるログイン画面が出てきます。この1画面で完結しないところはGoogleっぽいところがありますね。

FriendFeed(未ログインのログイン後、ログイン済み)

アプリ名、アプリのURLが表示されます。
また、アカウントとコネクトするとアプリは次のようなことができるって書いてあります。

  • プロフィールと全てのFeedへのアクセス
  • あなたの代わりのFriendFeedへのPOST

APIの各機能まで見ていないのでこの説明で足りているかわかりませんが、twitterよりは親切なのかなぁ。
設定変更をするためのリンク(Applications page)も提示していますね。

■ 使えるAPI

twitter

ほぼ全部(省略)

FriendFeed

(1) Reading data from FriendFeed

(2) Publishing to FriendFeed

  • /entry - Create, edit, or delete an entry
  • /comment - Create, edit, or delete a comment
  • /like - Create or delete a like
  • /subscribe - Subscribe to a feed
  • /unsubscribe - Unsubscribe from a feed
  • /feedinfo - Update profile information
  • /hide - Hide an entry
  • /short - Create an ff.im URL

■ まとめ

Feedback用のGroupってのが面白そう。
twitterにこれあったらMobsterなんとかのところは日本人からの書き込みで炎上してたのかも。
UIではFriendFeedが親切な気がするが、Scopeのようなものが1つしかないため、ユーザーの同意を得たConsumerアプリはなんでもできる。
FriendFeedにはDMみたいなものがないので問題にはならないのかも。

■ おまけ

FriendFeedのドキュメントに、「Installed Application Authentication」って書いてある部分が気になる。
これは、OAuthのリクエストにID/PWを組み合わせたFriendFeed独自仕様のようです。
言い換えると、CredentialはID/PWなんだけどリクエストはOAuthの形式っていう。