> ## Documentation Index
> Fetch the complete documentation index at: https://docs.truv.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Returning User

> Re-authenticate expired connections and refresh data

When a user's session expires or they change credentials, data refresh requests return `login_error` or `mfa_error`. Use Bridge update mode to prompt the user to re-authenticate their existing connection.

```mermaid theme={null}
sequenceDiagram
    participant Server as Your Server
    participant API as Truv API
    participant App as Your App
    participant Bridge as Truv Bridge

    Server->>API: Data refresh request
    API-->>Server: login_error / mfa_error
    Server->>API: Create bridge token (with access_token)
    API-->>Server: bridge_token
    Server->>App: Pass bridge_token
    App->>Bridge: TruvBridge.init() + open()
    Bridge->>Bridge: User re-authenticates
    Bridge-->>App: onSuccess
    API-->>Server: Webhook (task-status-updated, done)
    Server->>API: Retrieve updated data
```

***

## When to use

| Issue               | Description                                     | Refresh status |
| ------------------- | ----------------------------------------------- | -------------- |
| Changed credentials | User updated their username or password         | `login_error`  |
| MFA required        | Session expired, provider requires new MFA code | `mfa_error`    |

***

## Re-authenticate \[Server-side]

Create a new bridge token using the `access_token` from the original connection. This puts Bridge in update mode. The user re-enters credentials without going through employer search.

```bash theme={null}
curl --request POST \
     --url https://prod.truv.com/v1/users/USER_ID/tokens/ \
     --header 'X-Access-Client-Id: YOUR_TRUV_CLIENT_ID' \
     --header 'X-Access-Secret: YOUR_TRUV_CLIENT_SECRET' \
     --header 'Content-Type: application/json' \
     --data '{
  "product_type": "income",
  "access_token": "48427a36d43c4d5aa6324bc06c692456"
}'
```

```json theme={null}
{
  "bridge_token": "2f67984a110747d190c39e1022c81837"
}
```

## Re-authenticate with Bridge \[Client-side]

```html theme={null}
<script src="https://cdn.truv.com/bridge.js"></script>
<script>
  var bridgeToken = ''; // bridge_token from your server

  var bridge = TruvBridge.init({
    bridgeToken: bridgeToken,
    onSuccess: function(publicToken) {
      console.log('Re-authenticated successfully');
    },
    onClose: function() {
      console.log('Widget closed');
    }
  });

  bridge.open();
</script>
```

***

## Retrieve updated data \[Server-side]

After successful re-authentication, retrieve the refreshed data.

```bash theme={null}
curl --request GET \
     --url https://prod.truv.com/v1/links/d8a8945ee2b049b193110cfba643f5df/ \
     --header 'X-Access-Client-Id: YOUR_TRUV_CLIENT_ID' \
     --header 'X-Access-Secret: YOUR_TRUV_CLIENT_SECRET' \
     --header 'Accept: application/json'
```

***

## Next steps

<CardGroup cols={2}>
  <Card title="Data Refresh" icon="arrows-rotate" href="/developers/integration/embedded-orders/data-refresh">
    Refresh data without re-authentication
  </Card>

  <Card title="Task Lifecycle" icon="arrows-spin" href="/api-reference/tasks/lifecycle">
    Understand connection statuses
  </Card>

  <Card title="Bridge Token API" icon="key" href="/api-reference/bridge-token/users_tokens">
    Create bridge tokens
  </Card>

  <Card title="Bridge Events" icon="bolt" href="/developers/sdks/bridge-events">
    Client-side events and error codes
  </Card>
</CardGroup>
