SlideShare une entreprise Scribd logo
1  sur  23
Télécharger pour lire hors ligne
OAuth Echo
の Rails Gem
2011.12.21 第2.1回Twitter API勉強会 #twtr_hack
@tkawa
REST
REST
今回は関係ありません
OAuth Echo
TwitPic
• 画像アップロードサービス
• アカウント登録不要
• TwitterのID・パスワードも入力不要
• どうやって認証してるの?
OAuth Echo
• 認証をService Provider(Twitterなど)に
委譲するしくみ
• クライアントがOAuth登録してあれば、
事前の登録やトークン取得が不要
GET https://api.twitter.com/1/account/
verify_credentials.json
Authorization: OAuth
oauth_consumer_key="GDdmIQH6jhtmLUypg82g",
oauth_nonce="oElnnMTQIZvqvlfXM56aBLAf5noGD0A
QR3Fmi7Q6Y",
oauth_signature="U1obTfE7Rs9J1kafTGwufLJdspo%3D",
oauth_signature_method="HMAC-SHA1",
oauth_timestamp="1272325550",
oauth_token="819797-
Jxq8aYUDRmykzVKrgoLhXSq67TEa5ruc4GJC2rWimw",
oauth_version="1.0"
POST http://api.twitpic.com/2/upload.json
X-Auth-Service-Provider: https://api.twitter.com/1/
account/verify_credentials.json
X-Verify-Credentials-Authorization: OAuth
oauth_consumer_key="GDdmIQH6jhtmLUypg82g",
oauth_nonce="oElnnMTQIZvqvlfXM56aBLAf5noGD0A
QR3Fmi7Q6Y",
oauth_signature="U1obTfE7Rs9J1kafTGwufLJdspo%3D",
oauth_signature_method="HMAC-SHA1",
oauth_timestamp="1272325550",
oauth_token="819797-
Jxq8aYUDRmykzVKrgoLhXSq67TEa5ruc4GJC2rWimw",
oauth_version="1.0"
POST http://api.twitpic.com/2/upload.json
X-Auth-Service-Provider: https://api.twitter.com/1/
account/verify_credentials.json
X-Verify-Credentials-Authorization: OAuth
oauth_consumer_key="GDdmIQH6jhtmLUypg82g",
oauth_nonce="oElnnMTQIZvqvlfXM56aBLAf5noGD0A
QR3Fmi7Q6Y",
oauth_signature="U1obTfE7Rs9J1kafTGwufLJdspo%3D",
oauth_signature_method="HMAC-SHA1",
oauth_timestamp="1272325550",
oauth_token="819797-
Jxq8aYUDRmykzVKrgoLhXSq67TEa5ruc4GJC2rWimw",
oauth_version="1.0"
(ほぼ)これだけ
GET https://api.twitter.com/1/account/
verify_credentials.json
Authorization: OAuth
oauth_consumer_key="GDdmIQH6jhtmLUypg82g",
oauth_nonce="oElnnMTQIZvqvlfXM56aBLAf5noGD0A
QR3Fmi7Q6Y",
oauth_signature="U1obTfE7Rs9J1kafTGwufLJdspo%3D",
oauth_signature_method="HMAC-SHA1",
oauth_timestamp="1272325550",
oauth_token="819797-
Jxq8aYUDRmykzVKrgoLhXSq67TEa5ruc4GJC2rWimw",
oauth_version="1.0"
OAuth Echo
• Delegator(TwitPic)はリクエストごとに
Service Provider(Twitter)に認証を求める
• 1リクエストで完結する単純なAPIの実装
に向いている
• 認証だけなので、Service Provider(Twitter)
側に書き込んだりすることはできない
• 非公式仕様
- ほぼTwitterでしか使われていない
• OAuth 1.0仕様に基づいており、OAuth 2.0
になると使えない
- Google, Facebook, GitHubなどがOAuth 2.0
問題点?
class PostsController < ApplicationController
http_basic_authenticate_with :name =>
"tkawa", :password => "secret"
def index
render :json => { :message => "Limited
Access" }
end
...
end
かんたんBasic認証
class PostsController < ApplicationController
oauth_echo_authenticate_with :twitter
def index
render :json => { :message => "Limited
Access" }
end
...
end
かんたんOAuth Echo認証
https://github.com/tkawa/
oauth_echo_authentication
きっかけ
http://www.atmarkit.co.jp/news/201004/21/twitterapi.html
きっかけ
• Twitterのアノテーションの話がいつのま
にか消滅
• 自分で使いたい分だけでも自分で作る
か
Web認知行動療法
http://u2plus.jp/
開発中

Contenu connexe

Similaire à OAuth Echo の Rails Gem

ゼロからはじめるサーバーサイド Vol2
ゼロからはじめるサーバーサイド Vol2ゼロからはじめるサーバーサイド Vol2
ゼロからはじめるサーバーサイド Vol2
Taichi Inaba
 
Google App EngineでTwitterアプリを作ろう
Google App EngineでTwitterアプリを作ろうGoogle App EngineでTwitterアプリを作ろう
Google App EngineでTwitterアプリを作ろう
kenji4569
 
OAuth 2.0 MAC Authentication
OAuth 2.0 MAC AuthenticationOAuth 2.0 MAC Authentication
OAuth 2.0 MAC Authentication
Ryo Ito
 
第四回Web apiを使ってwebアプリケーションを作る勉強会テキスト2
第四回Web apiを使ってwebアプリケーションを作る勉強会テキスト2第四回Web apiを使ってwebアプリケーションを作る勉強会テキスト2
第四回Web apiを使ってwebアプリケーションを作る勉強会テキスト2
脇村 隆
 
Opauthライブラリによるtwitter,facebook認証について
Opauthライブラリによるtwitter,facebook認証についてOpauthライブラリによるtwitter,facebook認証について
Opauthライブラリによるtwitter,facebook認証について
松本 雄貴
 

Similaire à OAuth Echo の Rails Gem (20)

Anonymous OAuth Test
Anonymous OAuth TestAnonymous OAuth Test
Anonymous OAuth Test
 
Financial-grade API Hands-on with Authlete
Financial-grade API Hands-on with AuthleteFinancial-grade API Hands-on with Authlete
Financial-grade API Hands-on with Authlete
 
ゼロからはじめるサーバーサイド Vol2
ゼロからはじめるサーバーサイド Vol2ゼロからはじめるサーバーサイド Vol2
ゼロからはじめるサーバーサイド Vol2
 
Google App EngineでTwitterアプリを作ろう
Google App EngineでTwitterアプリを作ろうGoogle App EngineでTwitterアプリを作ろう
Google App EngineでTwitterアプリを作ろう
 
O Auth
O AuthO Auth
O Auth
 
OAuth 2.0 MAC Authentication
OAuth 2.0 MAC AuthenticationOAuth 2.0 MAC Authentication
OAuth 2.0 MAC Authentication
 
Azure Static Web Apps を試してみた!
Azure Static Web Apps を試してみた!Azure Static Web Apps を試してみた!
Azure Static Web Apps を試してみた!
 
後期02
後期02後期02
後期02
 
今更聞けないOAuth2.0
今更聞けないOAuth2.0今更聞けないOAuth2.0
今更聞けないOAuth2.0
 
第四回Web apiを使ってwebアプリケーションを作る勉強会テキスト2
第四回Web apiを使ってwebアプリケーションを作る勉強会テキスト2第四回Web apiを使ってwebアプリケーションを作る勉強会テキスト2
第四回Web apiを使ってwebアプリケーションを作る勉強会テキスト2
 
「金融API向けOAuth」にみるOAuthプロファイリングの実際 #secjaws #finsecjaws01 #oauth #oidc #api
「金融API向けOAuth」にみるOAuthプロファイリングの実際 #secjaws #finsecjaws01 #oauth #oidc #api「金融API向けOAuth」にみるOAuthプロファイリングの実際 #secjaws #finsecjaws01 #oauth #oidc #api
「金融API向けOAuth」にみるOAuthプロファイリングの実際 #secjaws #finsecjaws01 #oauth #oidc #api
 
Opauthライブラリによるtwitter,facebook認証について
Opauthライブラリによるtwitter,facebook認証についてOpauthライブラリによるtwitter,facebook認証について
Opauthライブラリによるtwitter,facebook認証について
 
API提供におけるOAuthの役割 #apijp
API提供におけるOAuthの役割 #apijpAPI提供におけるOAuthの役割 #apijp
API提供におけるOAuthの役割 #apijp
 
Twitter4jハンズオン 5/1 #twtr_hack
Twitter4jハンズオン 5/1 #twtr_hackTwitter4jハンズオン 5/1 #twtr_hack
Twitter4jハンズオン 5/1 #twtr_hack
 
React(TypeScript) + Go + Auth0 で実現する管理画面
React(TypeScript) + Go + Auth0 で実現する管理画面React(TypeScript) + Go + Auth0 で実現する管理画面
React(TypeScript) + Go + Auth0 で実現する管理画面
 
20100703devdo
20100703devdo20100703devdo
20100703devdo
 
【Open棟梁 汎用認証サイト】による認証ソリューション
【Open棟梁 汎用認証サイト】による認証ソリューション【Open棟梁 汎用認証サイト】による認証ソリューション
【Open棟梁 汎用認証サイト】による認証ソリューション
 
Azure AD による Web API の 保護
Azure AD による Web API の 保護 Azure AD による Web API の 保護
Azure AD による Web API の 保護
 
Windows.Web.Http.HttpClientとWebAuthenticationBroker
Windows.Web.Http.HttpClientとWebAuthenticationBrokerWindows.Web.Http.HttpClientとWebAuthenticationBroker
Windows.Web.Http.HttpClientとWebAuthenticationBroker
 
TwitterのOAuthってなんぞ?
TwitterのOAuthってなんぞ?TwitterのOAuthってなんぞ?
TwitterのOAuthってなんぞ?
 

Plus de Toru Kawamura

返信と@ツイートの仕様変更と提案 #twtr_hack
返信と@ツイートの仕様変更と提案 #twtr_hack返信と@ツイートの仕様変更と提案 #twtr_hack
返信と@ツイートの仕様変更と提案 #twtr_hack
Toru Kawamura
 

Plus de Toru Kawamura (12)

真のREST
真のREST真のREST
真のREST
 
RailsスタイルからRESTを学ぼう よちがや.rb
RailsスタイルからRESTを学ぼう よちがや.rbRailsスタイルからRESTを学ぼう よちがや.rb
RailsスタイルからRESTを学ぼう よちがや.rb
 
Web Clients for Ruby and What they should be in the future
Web Clients for Ruby and What they should be in the futureWeb Clients for Ruby and What they should be in the future
Web Clients for Ruby and What they should be in the future
 
RESTful #とは RailsスタイルからRESTを学ぼう
RESTful #とは RailsスタイルからRESTを学ぼうRESTful #とは RailsスタイルからRESTを学ぼう
RESTful #とは RailsスタイルからRESTを学ぼう
 
Hypermedia: The Missing Element to Building Adaptable Web APIs in Rails (増補日本語版)
Hypermedia: The Missing Element to Building Adaptable Web APIs in Rails (増補日本語版)Hypermedia: The Missing Element to Building Adaptable Web APIs in Rails (増補日本語版)
Hypermedia: The Missing Element to Building Adaptable Web APIs in Rails (増補日本語版)
 
Hypermedia: The Missing Element to Building Adaptable Web APIs in Rails
Hypermedia: The Missing Element to Building Adaptable Web APIs in RailsHypermedia: The Missing Element to Building Adaptable Web APIs in Rails
Hypermedia: The Missing Element to Building Adaptable Web APIs in Rails
 
RESTful Meetup vol.3 Introduction
RESTful Meetup vol.3 IntroductionRESTful Meetup vol.3 Introduction
RESTful Meetup vol.3 Introduction
 
Rails Gems realize RESTful modeling patterns
Rails Gems realize RESTful modeling patternsRails Gems realize RESTful modeling patterns
Rails Gems realize RESTful modeling patterns
 
リソースモデリングパターンの提案 #sendagayarb
リソースモデリングパターンの提案 #sendagayarbリソースモデリングパターンの提案 #sendagayarb
リソースモデリングパターンの提案 #sendagayarb
 
routes.rb をもう一度考えてみた #shibuyarb
routes.rb をもう一度考えてみた #shibuyarbroutes.rb をもう一度考えてみた #shibuyarb
routes.rb をもう一度考えてみた #shibuyarb
 
返信と@ツイートの仕様変更と提案 #twtr_hack
返信と@ツイートの仕様変更と提案 #twtr_hack返信と@ツイートの仕様変更と提案 #twtr_hack
返信と@ツイートの仕様変更と提案 #twtr_hack
 
RESTとRailsスタイル
RESTとRailsスタイルRESTとRailsスタイル
RESTとRailsスタイル
 

Dernier

Dernier (11)

Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
 
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
 
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
LoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイスLoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイス
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
 
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
 
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
 
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアルLoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
 
新人研修 後半 2024/04/26の勉強会で発表されたものです。
新人研修 後半        2024/04/26の勉強会で発表されたものです。新人研修 後半        2024/04/26の勉強会で発表されたものです。
新人研修 後半 2024/04/26の勉強会で発表されたものです。
 
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
 
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
 
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
 
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
 

OAuth Echo の Rails Gem