向我的oauth提供程序发出post请求时出现invalid_grant错误

时间:2018-05-31 15:03:03

标签: ruby-on-rails oauth-2.0 doorkeeper

我使用Doorkeeper gem将OAuth 2提供程序功能引入我的Rails应用程序。我将gem添加到gemfile,配置它并尝试发出post请求以获取访问令牌,如documentation中所述。

我向此网址发送了帖子请求 - http://localhost:3000/oauth/token 使用此参数:

client_id=c094523a20444ee3362e8eb33e08b5266cfb6486babe9f918c0c88104e67f6c0&client_secret=d6cebe57e475e685beb2401108438991e94f0078152d52a2da4d5f1307a4729c&code=c2f56975ba6970634deef1e256faa5de5b146f794f37b3c59f3b5111d6810ef6&grant_type=authorization_code&redirect_uri=urn:ietf:wg:oauth:2.0:oob

但我收到错误:

{"error":"invalid_grant","error_description":"The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client."}

我的门卫初始化程序:

Doorkeeper.configure do
  # Change the ORM that doorkeeper will use (needs plugins)
  orm :active_record

  # This block will be called to check whether the resource owner is authenticated or not.
  resource_owner_authenticator do
    current_user || warden.authenticate!(scope: :user)
  end
end

1 个答案:

答案 0 :(得分:0)

我在使用门卫4.3+时遇到了完全相同的问题 解决方案是使用门​​卫4.2.6