Sha256: cebac278bbcf5e345fba49beaadb6bc7ae22005308e84c67f8af69f690373d31

Contents?: true

Size: 677 Bytes

Versions: 7

Compression:

Stored size: 677 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("Superman").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

7 entries across 7 versions & 1 rubygems

Version Path
rack-oauth2-server-1.3.1 test/rails/app/controllers/api_controller.rb
rack-oauth2-server-1.3.0 test/rails/app/controllers/api_controller.rb
rack-oauth2-server-1.2.2 test/rails/app/controllers/api_controller.rb
rack-oauth2-server-1.2.1 test/rails/app/controllers/api_controller.rb
rack-oauth2-server-1.2.0 test/rails/app/controllers/api_controller.rb
rack-oauth2-server-1.1.1 test/rails/app/controllers/api_controller.rb
rack-oauth2-server-1.1.0 test/rails/app/controllers/api_controller.rb