i started using oauth2 gem with intridea ( http://github.com/intridea/oauth2 ) and don't know how to fix this problem. I have developed both a client and a server, and on request for access_token I do not see the grant_type parameter. My code is from a client callback controller
class CallbackController < Devise::OauthCallbacksController def accounts access_token = accounts_config.access_token_by_code(params[:code]) @user = User.find_for_accounts_oauth(access_token, signed_in_resource) if @user.persisted? && @user.errors.empty? sign_in @user set_oauth_flash_message :notice, :success redirect_to after_oauth_success_path_for(@user)
and from the user model
class User < ActiveRecord::Base devise :database_authenticatable, :oauthable def self.find_for_accounts_oauth(access_token, signed_in_resource=nil) data = ActiveSupport::JSON.decode(access_token.get(Settings.oauth.site + Settings.oauth.access_token_path)) if user = User.find_by_username(data["username"]) user else # Create an user with a stub password. User.create!(:username => data["username"], :password => Devise.friendly_token) end end end
Magazines from the supplier
Started POST "/oauth/token" for 127.0.0.1 at 2010-09-17 00:17:44 +0400 Processing by Oauth::TokenController
and from the client
Started GET "/users/oauth/accounts/callback? code=d264c2496d0dc5c494b7269f2f9e4c30cd55a571b6944d3231f63577acd12b1b&&expires_in=3599" for 127.0.0.1 at 2010-09-17 00:17:44 +0400 Processing by Devise::OauthCallbacksController#accounts as HTML Parameters: {"code"=>"d264c2496d0dc5c494b7269f2f9e4c30cd55a571b6944d3231f63577acd12b1b", "expires_in"=>"3599"} Completed in 343ms OAuth2::HTTPError (Received HTTP 400 during request.): Rendered /opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-3.0.0/lib/ action_dispatch/middleware/templates/rescues/_trace.erb (1.4ms) Rendered /opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-3.0.0/lib/ action_dispatch/middleware/templates/rescues/_request_and_response.erb (30.0ms) Rendered /opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-3.0.0/lib/ action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (36.7ms)
Any idea how to fix this?
source share