简体   繁体   English

OAuth2 :: doorkeeper错误

[英]OAuth2::Error with doorkeeper

Whenever I try to authenticate with doorkeeper provider, I always got the following error 每当我尝试向门卫提供商进行身份验证时,总是会遇到以下错误

invalid_grant: 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. {"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."}

I tried with other doorkeeper clients but still have the same error 我尝试了与其他门卫客户端,但仍然有相同的错误

Doorkeeper client: 门卫客户:

  1. https://github.com/doorkeeper-gem/doorkeeper-devise-client.git https://github.com/doorkeeper-gem/doorkeeper-devise-client.git
  2. http://dev.mikamai.com/post/112508735689/oauth2-on-rails-the-client-application http://dev.mikamai.com/post/112508735689/oauth2-on-rails-the-client-application

Doorkeeper provider: 门卫提供者:

https://github.com/doorkeeper-gem/doorkeeper-provider-app.git https://github.com/doorkeeper-gem/doorkeeper-provider-app.git

我通过将omniauth-oauth2 gem版本降级到此处提到的1.3.1来解决-https: //github.com/intridea/omniauth-oauth2/issues/81

Though downgrading to gem 'omniauth-oauth2', '~> 1.3.1' is a confirmed to be a solution, in Doorkeeper's Create-a-OmniAuth-strategy-for-your-provider Wiki Page it is mentioned that in your implementation of OmniAuth Strategy for Doorkeeper the following method should be present: 尽管降级为gem 'omniauth-oauth2', '~> 1.3.1'可以确认gem 'omniauth-oauth2', '~> 1.3.1'是一个解决方案,但在Doorkeeper的Create-a-OmniAuth-strategy-for-your-provider Wiki页面中 ,提到在实现中门卫OmniAuth策略应显示以下方法:

  # https://github.com/intridea/omniauth-oauth2/issues/81
  def callback_url
    full_host + script_name + callback_path
  end

There is long discussion in the referred omniauth-oauth2 issue #81 在提到的omn​​iauth-oauth2问题#81中进行了长时间的讨论

I personally faced the reported error when I was trying to test my Rails 5 Devise-based Doorkeeper Provider by using a Rails 5 Devise-based Client app to allow Provider's users connect their account on my client-app. 当我尝试通过使用基于Rails 5 Devise的客户端应用程序来测试基于Rails 5 Devise的Doorkeeper Provider时,我个人遇到了所报告的错误,以允许提供商的用户在我的客户端应用程序上连接其帐户。

In absence of the mentioned method in my OmniAuth::Strategies::Doorkeeper on front-end Devise OmniauthCallbacksController was flashing message Invalid Credentials and in the client-app server logs following error was seen: 在前端设备OmniAuth:OmniauthCallbacksController上的我的OmniAuth::Strategies::Doorkeeper缺少上述方法时,正在闪烁消息“ 无效凭据”,并且在客户端应用服务器日志中看到以下错误:

  Started GET "/users/auth/doorkeeper" for 127.0.0.1 at 2017-08-22 17:45:02 +0530
  I, [2017-08-22T17:45:02.386866 #14535]  INFO -- omniauth: (doorkeeper) Request phase initiated.
  Started GET "/users/auth/doorkeeper/callback?code=1b833bcc09651f98b0424a7afb1e60bd50fdcc765daf7d499bcefb5554457187&state=c215fd707ecd71c6ad0f6b5e58fa0d2da7210d86946d41e3" for 127.0.0.1 at 2017-08-22 17:45:03 +0530
  I, [2017-08-22T17:45:03.506424 #14535]  INFO -- omniauth: (doorkeeper) Callback phase initiated.
  E, [2017-08-22T17:45:03.523737 #14535] ERROR -- omniauth: (doorkeeper) Authentication failure! invalid_credentials: OAuth2::Error, invalid_grant: 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.
  {"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."}
  Processing by Users::OmniauthCallbacksController#failure as HTML
    Parameters: {"code"=>"1b833bcc09651f98b0424a7afb1e60bd50fdcc765daf7d499bcefb5554457187", "state"=>"c215fd707ecd71c6ad0f6b5e58fa0d2da7210d86946d41e3"}
  Redirected to http://localhost:5000/
  Completed 302 Found in 0ms (ActiveRecord: 0.0ms)

So adding that method to the strategy can be considered as an alternate solution. 因此,将该策略添加到策略中可以视为替代解决方案。

Thanks. 谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM