assaf/rack-oauth2-server — Issue #3: Documentation mentions oauth.scope, doesn't seem to exist
Author: slyphon
Created: 2012-01-09 19:10:14+00:00
State: open

Hey, trying to work out a minimal demo server to see how the flow works, and following along with the documentation I did this:

```ruby
require 'rubygems'
require 'bundler'
Bundler.setup(:default, :development)

require 'sinatra/base'
require 'rack/oauth2/sinatra'

class MyApp < Sinatra::Base
attr_reader :current_user

register Rack::OAuth2::Sinatra

oauth_required = '/private'

oauth.database = Mongo::Connection.new['oauth2_server_dev']

oauth.scope = %w{read write}	# <<-- this line

oauth.authenticator = lambda do |username,password|

if username == 'fungus' && password == 'fluffy'
"user_id_12345"
else
nil
end
end

before do
@current_user = { :id => 'user_id_12345' } if oauth.authenticated?
end

get "/monitor/check" do
'TEST-OK'
end

get '/private' do
"this is ur sekrits, user: #{current_user[:id]}"
end
end
```

But when I attempt to run it with rackup i get the following exception:

/Users/slyphon/git/dev/oauth2_server/app.rb:16:in `': undefined method `scope=' for # (NoMethodError)
from /Users/slyphon/git/dev/oauth2_server/app.rb:8:in `'
from /Users/slyphon/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/slyphon/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/slyphon/git/dev/oauth2_server/rackup.ru:3:in `block in

'
from /Users/slyphon/.rvm/gems/ruby-1.9.3-p0@oauth2_server/gems/rack-1.4.0/lib/rack/builder.rb:51:in `instance_eval'
from /Users/slyphon/.rvm/gems/ruby-1.9.3-p0@oauth2_server/gems/rack-1.4.0/lib/rack/builder.rb:51:in `initialize'
from /Users/slyphon/git/dev/oauth2_server/rackup.ru:1:in `new'
from /Users/slyphon/git/dev/oauth2_server/rackup.ru:1:in `

'
from /Users/slyphon/.rvm/gems/ruby-1.9.3-p0@oauth2_server/gems/rack-1.4.0/lib/rack/builder.rb:40:in `eval'
from /Users/slyphon/.rvm/gems/ruby-1.9.3-p0@oauth2_server/gems/rack-1.4.0/lib/rack/builder.rb:40:in `parse_file'
from /Users/slyphon/.rvm/gems/ruby-1.9.3-p0@oauth2_server/gems/rack-1.4.0/lib/rack/server.rb:200:in `app'
from /Users/slyphon/.rvm/gems/ruby-1.9.3-p0@oauth2_server/gems/rack-1.4.0/lib/rack/server.rb:301:in `wrapped_app'
from /Users/slyphon/.rvm/gems/ruby-1.9.3-p0@oauth2_server/gems/rack-1.4.0/lib/rack/server.rb:252:in `start'
from /Users/slyphon/.rvm/gems/ruby-1.9.3-p0@oauth2_server/gems/rack-1.4.0/lib/rack/server.rb:137:in `start'
from /Users/slyphon/.rvm/gems/ruby-1.9.3-p0@oauth2_server/gems/rack-1.4.0/bin/rackup:4:in `'
from /Users/slyphon/.rvm/gems/ruby-1.9.3-p0@oauth2_server/bin/rackup:19:in `load'
from /Users/slyphon/.rvm/gems/ruby-1.9.3-p0@oauth2_server/bin/rackup:19:in `

'

The line in question is #57 in README.rdoc