Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What are the params? #20

Closed
ebosantos opened this issue Apr 28, 2016 · 21 comments
Closed

What are the params? #20

ebosantos opened this issue Apr 28, 2016 · 21 comments

Comments

@ebosantos
Copy link

ebosantos commented Apr 28, 2016

I'm POSTing the following JSON to: /oauth/token

{ "grant_type": "assertion", "assertion": "social_provider_token" }

But I'm getting the following error message:

ArgumentError (wrong number of arguments (given 1, expected 3)):
doorkeeper-grants_assertion (0.0.1) lib/doorkeeper/request/assertion.rb:10:in `initialize'

initializers/doorkeeper.rb

resource_owner_from_credentials do |routes|
    User.authenticate(params[:email], params[:password], request.remote_ip)
end
resource_owner_from_assertion do
    User.find(2)
end
grant_flows %w[assertion authorization_code password client_credentials]

Could you please help me?

@biske
Copy link

biske commented Jul 14, 2016

+1

@matfiz
Copy link
Collaborator

matfiz commented Jul 14, 2016

@ebosantos @biske Please remember you also do have to provide client_id and client_secret, so the complete set of params would be:

$.post 'https://domain.com/oauth2/token',
  client_id: d017e2ecd288d3141478af6667d9b7e1401e40b9c8e6290c52ad345bd7b99fe8
  client_secret: 67ac711924cc8c46cd4395c13cfe4af91eda7408dc27afbf0303492445b02ffc
  grant_type: assertion
  assertion: <access_token>

@biske
Copy link

biske commented Jul 14, 2016

@matfiz, is it ok to expose client_secret on mobile devices?

@matfiz
Copy link
Collaborator

matfiz commented Jul 14, 2016

@biske I agree it is not safe- then they are not confidential any more and such OAuth2 consumer is called public client. Ref. http://stackoverflow.com/a/36304034/1851563

@NuckChorris
Copy link
Collaborator

This should probably not require client_secret — this only makes sense on server-side clients, and the "assertion" grant makes minimal sense in the context of a server-side client.

iirc (it's been a while since I read RFC 6749) public clients should not have a secret

@piya23300
Copy link

+1

@dsantosmerino
Copy link
Contributor

dsantosmerino commented Aug 2, 2016

I'm getting also the same error with cliend_id, client_secret, grant_type and assertion. Could you provide a valid example?

@biske
Copy link

biske commented Aug 2, 2016

@dsantosmerino, after adding client_id it works for me. Can you provide example app to reproduce issue?

@dsantosmerino
Copy link
Contributor

dsantosmerino commented Aug 2, 2016

@biske I'm trying to get the token from Postman, and this is my body request:
{ "client_id": "clientid", "client_secret": "secretid", "assertion": "32423444", "grant_type": "assertion" }

I've tried also providing de client info as get parameter, but I always get the same error than @ebosantos

ArgumentError (wrong number of arguments (given 1, expected 3)):
doorkeeper-grants_assertion (0.0.1) lib/doorkeeper/request/assertion.rb:10:in `initialize'

I have a password strategy with doorkeeper working properly but I need 3rd parties, like Fb.

@dsantosmerino
Copy link
Contributor

@biske I've found the problem. I was using http://rubygems.org as source and there are some needed changes not updated in the gem.

@adityamajeti
Copy link

I'm getting also the same error with cliend_id, client_secret, grant_type and assertion. How to resolve it?

@dsantosmerino
Copy link
Contributor

@adityamajeti I solved it just requiring the gem from this repo instead of rubygems.
gem 'doorkeeper-grants_assertion', git: 'https://github.com/Badiapp/doorkeeper-grants_assertion'

@adityamajeti
Copy link

adityamajeti commented Sep 2, 2016

Thanks, dsantosmerino

After adding that gem file my resource_owner_from_assertion is executed but after identifying user also i'm not getting access_token getting 404 error somthing like

message:
Document not found for class Doorkeeper::AccessToken with attributes {:application_id=>BSON::ObjectId('57c7131c2550c626d6eab983'), :resource_owner_id=>BSON::ObjectId('57c941fc2550c622e4d1f947'), :revoked_at=>nil}.
summary:
When calling Doorkeeper::AccessToken.find_by with a hash of attributes, all attributes provided must match a document in the database or this error will be raised.
resolution:
Search for attributes that are in the database or set the Mongoid.raise_not_found_error configuration option to false, which will cause a nil to be returned instead of raising this error.):

application id is taking internal db's app id but not taking fb app id

@matfiz
Copy link
Collaborator

matfiz commented Sep 2, 2016

@adityamajeti Can you show us your resource_owner_from_assertion?

@adityamajeti
Copy link

adityamajeti commented Sep 2, 2016

resource_owner_from_assertion do
facebook = URI.parse('https://graph.facebook.com/me?access_token=' + params[:assertion])
response = Net::HTTP.get_response(facebook)
user_data = JSON.parse(response.body)
# User.find_by_facebook_id(user_data['id'])
User.find_by uid:user_data['id']
end

one more thing in my application I want fb and eamil intregartion

@adityamajeti
Copy link

@dsantosmerino, I'm using doorkeeper 4.0.0.rc1 gem to generate access_token. but this gem 'doorkeeper-grants_assertion', git: 'https://github.com/Badiapp/doorkeeper-grants_assertion' requires gem doorkeeper 4.0.0. while changing 4.0.0. my doorkeeper logic is not working could you pl help me

@dsantosmerino
Copy link
Contributor

dsantosmerino commented Sep 5, 2016

hey @adityamajeti, I didn't try it, but you can fork this repo and modify your required doorkeeper version. Anyway, I've realized that I copy-pasted our fork (from Badiapp), I wanted to say the original one, something like
gem 'doorkeeper-grants_assertion', git: 'https://github.com/doorkeeper-gem/doorkeeper-grants_assertion'

@dsantosmerino
Copy link
Contributor

dsantosmerino commented Sep 5, 2016

BTW, I would like to know how many people are actively using this gem. We need to take care about it and maintain the integration with doorkeeper main project. @tute do you have any suggestion or idea to improve this repo? We could start fixing the RubyGems version.

@tute
Copy link
Contributor

tute commented Sep 5, 2016

Thanks for the text, @dsantosmerino. If you send over PRs improving the gem I will merge them, and then grant you access as maintainer if it's your will.

@thijsnado
Copy link

@ebosantos @tute I think this is fixed on master. Maybe all we need is a 0.0.2 release.

@matfiz
Copy link
Collaborator

matfiz commented Jan 16, 2018

This is fixed in the latest release, closing

@matfiz matfiz closed this as completed Jan 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants