doorkeeper-gem / doorkeeper-grants_assertion

Assertion grant extension for Doorkeeper. Born from: https://github.com/doorkeeper-gem/doorkeeper/pull/249
MIT License
82 stars 53 forks source link

Google Oauth assertion failing? #38

Open waclock opened 1 year ago

waclock commented 1 year ago

Hello,

I'm having trouble setting up grants_assertion with google. I've setup doorkeeper and currently have a react-native app that is getting an idToken, accessToken and code. This is doing so, by using a specific iOS Client ID.

I'm then sending the idToken as the assertion to be checked by doorkeeper, like so:

Doorkeeper.configure do
  resource_owner_from_assertion do
    if server.client && params[:provider] && params[:assertion]
      auth = Doorkeeper::GrantsAssertion::Devise::OmniAuth.auth_hash(
        provider: params.fetch(:provider),
        assertion: params.fetch(:assertion)
      )
      User.where(email: auth.info.email).first if auth
    end
  end
  # add your supported grant types and other extensions
  grant_flows %w(assertion authorization_code implicit password client_credentials)
end

I've setup as my env variables in rails a specific Client ID and client secret for my rails server. However, every time I try validating the passed assertion, I get the following error:

{
  "error_description": "Invalid Value"
}

I've tried passing the idToken, accessToken and also directly calling Doorkeeper::GrantsAssertion::OmniAuth.oauth2_wrapper with different combinations of client_id and client_secret, but unfortunately nothing has worked so far. I'm using rails 7 and ruby 3. Is this library still working with Google Oauth? Any help would be appreciated, thanks.

1997roylee commented 1 year ago

I faced this problem and I decided to create a google auth service to validate the auth code to solve this problem.