I have a frontend (SPA, angular2, lite-server) and a hidden backend (not exposed to public, i.e. localhost:8080, spring boot+spring security), frontend can access backend by proxying frontend/api
calls to backend/api
under the hood.
Basically, the steps for this kind of OAuth2 flow are:
- On UI - hit url to authorization server with redirect_uri specified
- Authorize
- Get back to redirect_uri with access code
- ???
- Server exchanges access code for an authorization token and keeps it
- User(authenticated) gets back to the page he was restricted to access
I can't get the steps between 3 and 5. As my backend server is invisible, the redirect_uri should be the one in the frontend. I could possibly use a frontend/api/auth
which will proxy the call to backend/api/auth
and backend will succesfully get the authorization grant however in this case user won't be redirected back to a frontend. So, should I get the code in the javascript and do a POST to /api/auth
from the javascript instead?
Also I don't get how to get back to step 6 after that as after all redirects SPA app will be reloaded(dropping the state) and redirect_uri is an url to /api/auth
.