Note that there are some explanatory texts on larger screens.

plurals
  1. POWeb Server Flow in the Rack OAuth-2 Server
    text
    copied!<p>I'm trying to integrate the <a href="https://github.com/flowtown/rack-oauth2-server" rel="nofollow">Rack OAuth-2 server</a> into my sinatra application, to use it in a <a href="http://tools.ietf.org/html/draft-ietf-oauth-v2-10#section-2" rel="nofollow">web-server flow implementation</a> and I can't make it work :(. I the following code in the oauth controller</p> <pre><code>require "rack/oauth2/sinatra" module RestKit module Network class OAuth2 &lt; Sinatra::Base use Rack::Logger set :sessions, true set :show_exceptions, true ENV["DB"] = "test" DATABASE = Mongo::Connection.new[ENV["DB"]] register Rack::OAuth2::Sinatra oauth.authenticator = lambda do |username, password| "Batman" if username == "cowbell" &amp;&amp; password == "more" end oauth.host = "localhost" oauth.database = DATABASE # 3. Obtaining End-User Authorization before "/oauth/*" do halt oauth.deny! if oauth.scope.include?("time-travel") # Only Superman can do that end get "/oauth/authorize" do "client: #{oauth.client.display_name}\nscope: #{oauth.scope.join(", ")}\nauthorization: #{oauth.authorization}" end post "/oauth/grant" do oauth.grant! "Batman" end post "/oauth/deny" do oauth.deny! end # 5. Accessing a Protected Resource before { @user = oauth.identity if oauth.authenticated? } oauth_required "/user" get "/user" do @user end get "/list_tokens" do oauth.list_access_tokens("Batman").map(&amp;:token).join(" ") end end end end </code></pre> <p>Then I try to obtain an authorization code using curl from terminal with:</p> <pre><code>curl -i http://localhost:4567/oauth/authorize -F response_type=code -F client_id=[the ID] -F client_secret=[the secret] -F redirect_uri=http://localhost:4567/oauth/showcode </code></pre> <p>and Just I got as a response:</p> <pre><code>HTTP/1.1 400 Bad Request </code></pre> <p>Content-Type: text/plain Content-Length: 20 Connection: keep-alive Server: thin 1.2.11 codename Bat-Shit Crazy</p> <p>Missing redirect URL</p> <p>Do you have any ideas what I'm doing wrong? Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload