Sha256: 7c26bc8869604621080183f8f6b6745045fc00dd01d46f6e2981a1a1749862df

Contents?: true

Size: 675 Bytes

Versions: 60

Compression:

Stored size: 675 Bytes

Contents

class ApiController < ApplicationController

  oauth_required :only=>[:private, :change]
  oauth_required :only=>[:calc], :scope=>"math"

  def public
    if oauth.authenticated?
      render :text=>"HAI from #{oauth.identity}"
    else
      render :text=>"HAI"
    end
  end

  def private
    render :text=>"Shhhh"
  end

  def change
    render :text=>"Woot!"
  end

  def calc
    render :text=>"2+2=4"
  end

  def list_tokens
    render :text=>oauth.list_access_tokens("Batman").map(&:token).join(" ")
  end

  def user
    render :text=>current_user.to_s
  end

protected

  def current_user
     @current_user ||= oauth.identity if oauth.authenticated?
  end
  
end

Version data entries

60 entries across 33 versions & 2 rubygems

Version Path
rack-oauth2-server-2.8.1 test/rails2/app/controllers/api_controller.rb
rack-oauth2-server-2.8.1 test/rails3/app/controllers/api_controller.rb
rack-oauth2-server-2.8.0 test/rails3/app/controllers/api_controller.rb
rack-oauth2-server-2.8.0 test/rails2/app/controllers/api_controller.rb
rack-oauth2-server-2.7.0 test/rails2/app/controllers/api_controller.rb
rack-oauth2-server-2.7.0 test/rails3/app/controllers/api_controller.rb
rack-oauth2-server-2.6.1 test/rails3/app/controllers/api_controller.rb
rack-oauth2-server-2.6.1 test/rails2/app/controllers/api_controller.rb
rack-oauth2-server-2.6.0 test/rails2/app/controllers/api_controller.rb
rack-oauth2-server-2.6.0 test/rails3/app/controllers/api_controller.rb
rack-oauth2-server-2.5.1 test/rails3/app/controllers/api_controller.rb
rack-oauth2-server-2.5.1 test/rails2/app/controllers/api_controller.rb
rack-oauth2-server-2.5.0 test/rails3/app/controllers/api_controller.rb
rack-oauth2-server-2.5.0 test/rails2/app/controllers/api_controller.rb
rack-oauth2-server-2.4.2 test/rails2/app/controllers/api_controller.rb
rack-oauth2-server-2.4.2 test/rails3/app/controllers/api_controller.rb
rack-oauth2-server-2.4.1 test/rails2/app/controllers/api_controller.rb
rack-oauth2-server-2.4.1 test/rails3/app/controllers/api_controller.rb
rack-oauth2-server-2.4.0 test/rails3/app/controllers/api_controller.rb
rack-oauth2-server-2.4.0 test/rails2/app/controllers/api_controller.rb