简体   繁体   中英

Getting invalid_grant error when make post request to my oauth provider

I use the Doorkeeper gem to introduce OAuth 2 provider functionality to my Rails application. I added the gem to gemfile, configure it and trying to make post request to get access token as described in the documentation .

I sent post request to this url - http://localhost:3000/oauth/token with this parameters:

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

But I get the error:

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

My doorkeeper initializer:

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

我与门卫4.3+完全相同的问题解决方案是使用门​​卫4.2.6

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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