# Token login

Source: https://developers.swell.is/storefronts-v1/token-login

Token login allows authenticated users access to their Swell-hosted account and order information without needing to log in a second time. This is useful for sellers and merchants that have an existing third-party user authentication service and wish to use it in their Swell store.

For example, let’s say you’re a merchant who manages a blog and a Swell store. When a customer logs in to your blog, token login also lets them access their Swell account. This saves customers from having to log in twice.

> **Note:** Swell uses the bycrpt algorithm to hash passwords.

### Set up token login

To bypass the standard Swell user login, generate a password token on the backend using the Swell API and then send it to the client application.

**1. Make a request from your front-end app to your server.**

`Client.js`

```javascript
const response = await axios.get('/api/generateToken', {
  params: {
    email: '<user email>'
  }
});
const token = response.data.password_token;
```

**2. Generate a token within your server-side API route or backend service.**

**Node**

```javascript
const email = req.query.email

// Respond with password_token created on the account object
const response = await swell.put(`/accounts/${email}`, {
  password_token: null
})

res.status(200).json(response)
```

**3. Login client app with returned token.**

**swell.js**

```javascript
await swell.account.login('<email>', {
  password_token: token
})
```

### Next steps

Great job—you have successfully set up token login for your store. Check out our [core concepts guide series](https://developers.swell.is/guides/core-concepts/platform-overview) for more details about Swell models and their usage.
