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

How to send oauth token authentication to another client server #493

Closed
jkpulido opened this Issue Apr 27, 2017 · 4 comments

Comments

Projects
None yet
3 participants
@jkpulido
Copy link

jkpulido commented Apr 27, 2017

Forgive me for my English.

I do not know what is the proper way to do the following:

I have two servers:
 - localhost:3030 where the feathers server is, and
 - localhost:8080 where I have my frontend developed with vuejs and feathers-vuex

In localhost:8080/#/ I have a link that redirects to the server feahters localhost:3030/auth/facebook. the user registers correctly and redirects me to "successRedirect": "/auth/success". The token is stored in cookies. I also have this route:

app.get('/auth/success', function(req, res){
  // at this point what is the best way to get the generated token to be sent back to my other client server: localhost: 8080.

  // I do not think this is the best way but I thought to do it like this:
  res.redirect('http://localhost:8080/#/token/' + mytoken)
});

When I get the token in my vuejs I can simply do it.

this.$store.dispatch('auth/authenticate', {
  type: 'token',
  token: mytoken
})

This action is from feathers-vuex. Same as feathersClient.authenticate()

This gives me some concerns.

  • it is recommended to send the token in the URL. Is there any way to make it better?

  • can you send the token that is generated in the feathersjs server in real time to the client?

I'm starting with feathersjs and vuejs I hope you can guide me. If I have done something wrong forgive me.

Thank you very much, greetings from PERU

@marshallswain

This comment has been minimized.

Copy link
Member

marshallswain commented Apr 27, 2017

You can send the token in a URL. Just make sure you use SSL. Here's a gist with an example of how to make it happen:

https://gist.github.com/marshallswain/3c9e5b3b177b977468b5b711b6254f67

@jkpulido

This comment has been minimized.

Copy link
Author

jkpulido commented Apr 27, 2017

Thank you very much, it was what I needed :)

@marshallswain

This comment has been minimized.

Copy link
Member

marshallswain commented Apr 27, 2017

Great!

@jhlabs

This comment has been minimized.

Copy link

jhlabs commented Aug 11, 2017

@marshallswain I followed your gist exactly and retrieved the token within vue.js to store it in localStorage. Now when I try to authenticate() with this token I receive the following error:

image

How can I submit the userId as payload as well? I am not sending a strategy as payload with the authenticate() method, as this is the recommended way in the feathers docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.