I'm currently working on building a REST API where users can authenticate themselves via different passport strategies (google
, facebook
). The authentication has to be done without a session.
Now I've already worked on the local strategy and that works like so;
application POST /login
to API and then when the user entered the right credentials they will get some payload back like so
[
{
"tokenType": "refresh",
"expiresIn": 604800000,
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTUsImlhdCI6MTY0MDc4NzA4MCwiZXhwIjoxNjQxMzkxODgwfQ.zdxdpX8NkiSTsbZj0xOd18RdbLjeSsQpkikLGW71xrE"
},
{
"tokenType": "access",
"expiresIn": 7200000,
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTUsImlhdCI6MTY0MDc4NzA4MCwiZXhwIjoxNjQwNzk0MjgwfQ.EBDuJqQYT-D0bnYbC76_khe6b29c80R4pMyEaBNKLKE"
}
]
However, the problem with the google
and facebook
strategy is that they work via OAuth
. I'm struggling to find a way to send the above information (like with my local strategy) to the client after the OAuth authentication has succeeded.
These OAuth services work with a return URL like /auth/facebook/return
. But this return URL is on the API which then can't send the information over to the client (or can it?).
How can I do this?