S
S
Senbonzakuraa2020-08-24 19:14:37
Node.js
Senbonzakuraa, 2020-08-24 19:14:37

How is authorization through the social. networking in a React and Express site?

I don't understand how authorization happens in a React application. For example:

  1. From the client I go to /auth/vk
  2. On the VK site I give permission to enter using my account
  3. After that, I am transferred to the /auth/vk/callback server and returns account information
  4. Then I register this user on my server and create a jwt token

Question - How to send this jwt to react?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Robur, 2020-08-25
@Robur

I don't know about vk. but "social networks" use oauth to varying degrees.
The scheme with oauth is most often like this:
3. after that, I am transferred to my application (which is on react), which receives a token from the url parameters and saves it in local storage
4. my application (react) goes to the server (express) with this token to register a user.
5. The server checks the token for validity (by requesting a social network or something else) and if everything is OK, it creates a user/session/does whatever.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question