V
V
Viktor Arkhipov2017-08-12 22:49:38
Angular
Viktor Arkhipov, 2017-08-12 22:49:38

How to pass jwt to client in Angular?

Hello, there is an application on Angular, it implements jwt authorization.
The token is written to local storage after an http request from a form.
Problem:
You can enter the application through another site, such as VK / FB, etc. It turns out that the client has to go to the site through which he wants to log in, then after successful authorization he will be redirected back to the application.
So, what is the best way to pass the generated token, because I can’t send json, because You also need to render the page with the application.
Will I have to use cookies/sessions in this case? Or are there any other solutions

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dasha Tsiklauri, 2017-08-12
@paul-smith

see how oauth works, in short: after successful authorization, the site of the social. network should redirect to yours with an authorization code (for example, to mysite.com/#code=abcdef), the main site should process location.hash on the master component (immediately, for example, the case of #error=code) and exchange the code for a jwt token during initialization

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question