# 4. Add authentication routes

Making use of the passport SIWW strategy and the token library, we defined the oAuth2 routes.

```
const express = require('express');
const router = express.Router();
const authToken = require('../authenticate/token');
const passportSIWW = require("../authenticate/passport_siww");    

// login via passport-wallet + SIWW
router.get('/siww',passportSIWW.authenticate('SIWW', {session: false}));
router.get('/siww/callback', passportSIWW.authenticate('SIWW', {
    failureRedirect: '/auth/unauthorized',
    session: false
}), function (req, res) {

    // make the auth cookie and redirect
    let token=authToken.createToken(req);
    res.cookie(authToken.getCookieName(), token, authToken.getCookieOptions());
        res.redirect('/app');
    });

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://incubiq.gitbook.io/siww/use-cases/nodejs-backend-implementation/4.-add-authentication-routes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
