feathersjs-ecosystem / authentication-oauth2

[MOVED] OAuth 2 plugin for feathers-authentication
https://github.com/feathersjs/feathers
MIT License
26 stars 15 forks source link

Cannot use Passport-Google-Token through POST request on /authentication #83

Closed jk1z closed 6 years ago

jk1z commented 6 years ago

User cannot use Passport-Google-Token through POST request on /authentication. It works on the previous version of authentication-oauth2 which is the one without the '@'.

Steps to reproduce

  1. Create a feathersjs app using feathersjs cli.

  2. Add a users service and google login authentication through cli.

  3. Modify the authentication.js and default.json a bit for adapting Passport-Google-Token. authentication.js code

  4. Get Client secret and ID from google api console. default.json code

  5. Get the access token from an app.

  6. Post to /authentication with {"strategy":"google", "access_token": "google access token"}

  7. Response failed response

Expected behavior

The application should return user a JWT token

Actual behavior

google strategy is not permitted.

System configuration

Module versions (especially the part that's not working): @featherjs/authentication: github:feathersjs/authentication @featherjs/authentication-oauth2: ^1.1.0

NodeJS version: 10.7.0

Operating System: Linux inside of nodejs docker image

Browser Version: Postman

daffl commented 6 years ago

You have to add all strategy names you want to use as a valid strategy to the authenticate hook at before create on the authentication service.

jk1z commented 6 years ago

Thanks for the help. I was following one of the FBSDK issue. It didn't mention you need to add strategy name into the before create authentication service at all. I guess that issue's solution is outdated?

daffl commented 6 years ago

Which issue is that?

jk1z commented 6 years ago

https://github.com/feathersjs/authentication-oauth2/issues/22

daffl commented 6 years ago

Yes, it's the same thing, you just have to update the strategies in your configuration to include the name of the strategy you want to use to authenticate. This is usually done in the authentication.strategies section in config/default.json.

jk1z commented 6 years ago

Anyway, thank you so much for the help. Also, since I saw on #22, we need an example or tutorial on how to setup the oauth token strategy. I took some time and made this article https://medium.com/@jackzhang0096/how-to-setup-oauth-2-0-token-strategy-on-feathersjs-1d77cc32118b. Hopefully, it will be useful when someone else stuck on the same problem.

daffl commented 6 years ago

Awesome, thank you so much for writing this up! I'm assuming we can close this then?