SlideShare a Scribd company logo
1 of 23
Download to read offline
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/
開発中

More Related Content

Similar to OAuth Echo の Rails Gem

Anonymous OAuth Test
Anonymous OAuth TestAnonymous OAuth Test
Anonymous OAuth TestRyo Ito
 
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 AuthleteTatsuo Kudo
 
ゼロからはじめるサーバーサイド Vol2
ゼロからはじめるサーバーサイド Vol2ゼロからはじめるサーバーサイド Vol2
ゼロからはじめるサーバーサイド Vol2Taichi 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 AuthenticationRyo Ito
 
Azure Static Web Apps を試してみた!
Azure Static Web Apps を試してみた!Azure Static Web Apps を試してみた!
Azure Static Web Apps を試してみた!一希 大田
 
今更聞けないOAuth2.0
今更聞けないOAuth2.0今更聞けないOAuth2.0
今更聞けないOAuth2.0Takahiro Sato
 
第四回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 #apiTatsuo Kudo
 
Opauthライブラリによるtwitter,facebook認証について
Opauthライブラリによるtwitter,facebook認証についてOpauthライブラリによるtwitter,facebook認証について
Opauthライブラリによるtwitter,facebook認証について松本 雄貴
 
API提供におけるOAuthの役割 #apijp
API提供におけるOAuthの役割 #apijpAPI提供におけるOAuthの役割 #apijp
API提供におけるOAuthの役割 #apijpTatsuo Kudo
 
Twitter4jハンズオン 5/1 #twtr_hack
Twitter4jハンズオン 5/1 #twtr_hackTwitter4jハンズオン 5/1 #twtr_hack
Twitter4jハンズオン 5/1 #twtr_hackYusuke Yamamoto
 
React(TypeScript) + Go + Auth0 で実現する管理画面
React(TypeScript) + Go + Auth0 で実現する管理画面React(TypeScript) + Go + Auth0 で実現する管理画面
React(TypeScript) + Go + Auth0 で実現する管理画面KentaEndoh
 
【Open棟梁 汎用認証サイト】による認証ソリューション
【Open棟梁 汎用認証サイト】による認証ソリューション【Open棟梁 汎用認証サイト】による認証ソリューション
【Open棟梁 汎用認証サイト】による認証ソリューションDaisuke Nishino
 
Azure AD による Web API の 保護
Azure AD による Web API の 保護 Azure AD による Web API の 保護
Azure AD による Web API の 保護 junichi anno
 
Windows.Web.Http.HttpClientとWebAuthenticationBroker
Windows.Web.Http.HttpClientとWebAuthenticationBrokerWindows.Web.Http.HttpClientとWebAuthenticationBroker
Windows.Web.Http.HttpClientとWebAuthenticationBrokerNobuaki Aoki
 
TwitterのOAuthってなんぞ?
TwitterのOAuthってなんぞ?TwitterのOAuthってなんぞ?
TwitterのOAuthってなんぞ?deflis
 

Similar to 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ってなんぞ?
 

More from Toru Kawamura

RailsスタイルからRESTを学ぼう よちがや.rb
RailsスタイルからRESTを学ぼう よちがや.rbRailsスタイルからRESTを学ぼう よちがや.rb
RailsスタイルからRESTを学ぼう よちがや.rbToru Kawamura
 
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 futureToru Kawamura
 
RESTful #とは RailsスタイルからRESTを学ぼう
RESTful #とは RailsスタイルからRESTを学ぼうRESTful #とは RailsスタイルからRESTを学ぼう
RESTful #とは RailsスタイルからRESTを学ぼうToru Kawamura
 
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 (増補日本語版)Toru Kawamura
 
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 RailsToru Kawamura
 
RESTful Meetup vol.3 Introduction
RESTful Meetup vol.3 IntroductionRESTful Meetup vol.3 Introduction
RESTful Meetup vol.3 IntroductionToru Kawamura
 
Rails Gems realize RESTful modeling patterns
Rails Gems realize RESTful modeling patternsRails Gems realize RESTful modeling patterns
Rails Gems realize RESTful modeling patternsToru Kawamura
 
リソースモデリングパターンの提案 #sendagayarb
リソースモデリングパターンの提案 #sendagayarbリソースモデリングパターンの提案 #sendagayarb
リソースモデリングパターンの提案 #sendagayarbToru Kawamura
 
routes.rb をもう一度考えてみた #shibuyarb
routes.rb をもう一度考えてみた #shibuyarbroutes.rb をもう一度考えてみた #shibuyarb
routes.rb をもう一度考えてみた #shibuyarbToru Kawamura
 
返信と@ツイートの仕様変更と提案 #twtr_hack
返信と@ツイートの仕様変更と提案 #twtr_hack返信と@ツイートの仕様変更と提案 #twtr_hack
返信と@ツイートの仕様変更と提案 #twtr_hackToru Kawamura
 
RESTとRailsスタイル
RESTとRailsスタイルRESTとRailsスタイル
RESTとRailsスタイルToru Kawamura
 

More from 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スタイル
 

Recently uploaded

スマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システムスマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システムsugiuralab
 
論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A survey論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A surveyToru Tamaki
 
SOPを理解する 2024/04/19 の勉強会で発表されたものです
SOPを理解する       2024/04/19 の勉強会で発表されたものですSOPを理解する       2024/04/19 の勉強会で発表されたものです
SOPを理解する 2024/04/19 の勉強会で発表されたものですiPride Co., Ltd.
 
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介Yuma Ohgami
 
論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNet論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNetToru Tamaki
 
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...Toru Tamaki
 
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略Ryo Sasaki
 
TSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdfTSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdftaisei2219
 
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)Hiroki Ichikura
 

Recently uploaded (9)

スマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システムスマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システム
 
論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A survey論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A survey
 
SOPを理解する 2024/04/19 の勉強会で発表されたものです
SOPを理解する       2024/04/19 の勉強会で発表されたものですSOPを理解する       2024/04/19 の勉強会で発表されたものです
SOPを理解する 2024/04/19 の勉強会で発表されたものです
 
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
 
論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNet論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNet
 
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
 
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
 
TSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdfTSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdf
 
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
 

OAuth Echo の Rails Gem