Skip to content

Instantly share code, notes, and snippets.

Created Sep 17, 2010
What would you like to do?
# environment.rb
# These are models you should define. (you can change the model name, of course)
# * Oauth2::AccessToken do |config|
require 'rack/oauth2'
oauth2_authenticator = lambda do |request|
access_token = Oauth2::AccessToken.find_by_token(request.access_token)
if access_token.blank?
request.invalid_token! "Given access token is invalid."
elsif access_token.expired?
request.expired_token! "Given access token has been expired."
elsif access_token.revoked?
request.invalid_token! "Given access token has been revoked."
config.middleware.insert_before(RestfulJsonpMiddleware, Rack::OAuth2::Server::Resource, "", &oauth2_authenticator)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment