OAuth認証+JavaからTwitterにポスト その4

週1のペースでまったりと続くこの企画。

前回はrequest_tokenを取得しました。

今日やるのは↓の2と3のところ

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.


request_tokenではまだAPIにアクセスすることはできません。
APIにアクセスするにはaccess_tokenが必要です。
そのaccess_tokenの取得の際に必要な7 digit PINを今回は取得します。



実はあっさり終わります。
まず2番。

http://twitter.com/oauth/authorize?oauth_token=REQUEST_TOKEN
# REQUEST_TOKENはこの前取得したやつに置き換えて下さい。


こういうページに飛びます。

許可します。

で、次、3番

7桁の番号が表示されます。

You've successfully granted access to tvvitter(クライアントの名前)
って表示されてますね。つまりconsumerがuserの代わりにService Providerにアクセスするのを今のクリックで承認したわけです。


以上。ちょっとテキトーすぎるかもしれないけどw