0

I would like to create a link that could POST data. Actually, I have a front in vuejs and a backend in rails. I already have my own authentication system with Devise gem. And I would like a user (who is already logged in) to be able to connect to other omniauth services (github, google...).

The problem is that as soon as I go on the link /auth/github (for example) my backend tells me that I didn't send the user's authentication token because i don't know how to send it.

That's why I would like to send datas (here, the auth token) directly from the link

Thanks

Theo Cerutti
  • 779
  • 1
  • 10
  • 33

1 Answers1

0

Like @Eyeslandic pointed out, your title is misleading, you have an OAuth or OAuth2 problem not a link problem.

If I can guess correctly you are getting a Get response (the token is in the link) and you want it to be a post response (the token in the request body) ... Are you using passport.js ? Must be a matter of configuration.

There is nothing wrong with receiving the token in the link, OAuth protocols are secure enough, whether it's a Get or a Post response.

If you want to read the token from the link, check this answer.

login.get('/p', function(req, res) {
    const token = req.query.theReturnedTokenNameInTheLink
    res.send("My token is " + token);
});

And the token is just a key that give you access to the host (github, google, facebook ...) Api, you should make another request to those API's, in order to get the user data, you could use a library like passport.js to simplify things, here is one of the tutorials, I found on how to use passport.js

Good luck.

Fennec
  • 1,535
  • 11
  • 26
  • No, I think I explained it wrong. In fact I am already connected and I already have my token. What I want to do is to open a page, the one to authorize an omniauth application, by making a html GET (through the tag) on my backend so that it redirects me to this page. The problem is that my backend asks for the authentication token to redirect me to the omniauth authorization page. – Theo Cerutti Jan 27 '21 at 12:17