---
title: "PHP, Python, .NET or Node.js: install the client"
description: "Install the Block-Auth client on your server."
url: "/sdk-integration-server-install/"
language: "en"
guide: "PHP, Python, .NET, Node.js"
step: "Quickstart step 1 of 3, required"
---

# Install the client

First your environment variables, then the Block-Auth client for your language.

## Your environment variables

Before you touch any code, set up your server environment variables. Pick the keys based on where your app is going to run. Each environment has its own in [Applications » Integration details](/integration-quickstart.md#apps-retrieve-keys), and they don't mix:

| Where your app runs         | Which keys to use                                                                                                    | Where you put them                  |
| --------------------------- | -------------------------------------------------------------------------------------------------------------------- | ----------------------------------- |
| Your computer (`localhost`) | The **Development** ones. They work right away.                                                                      | The `.env` on your computer         |
| Your live server            | The **Production** ones. They work once you [validate your domain](/integration-quickstart.md#apps-validate-domain). | Your server's environment variables |

Put these variables in your server environment. Here they are with your data:

`APP_URL` in development is the URL where your backend runs: Node.js `http://localhost:4000`, PHP `http://localhost:8080`, Python (Flask) `http://localhost:5000`, Python (FastAPI) `http://localhost:8000`, .NET `http://localhost:5000`.

#### Node.js · development

In a .env next to your backend package.json. Load it with `node --env-file=.env` (Node 20.6+) or the `dotenv` package (`import 'dotenv/config'` at the top of your entry file).

**.env**

```dotenv
APP_URL=http://localhost:4000
BLOCKAUTH_API_KEY=your_api_key
BLOCKAUTH_API_SECRET=<paste the API Secret from the Dashboard>
SESSION_SECRET=<generate one: openssl rand -hex 32>
```

#### Node.js · production

Set them in your server or platform (Docker, your hosting…), not in a file you upload with your code.

**Environment variables on your server**

```dotenv
APP_URL=https://your-app.com
BLOCKAUTH_API_KEY=your_api_key
BLOCKAUTH_API_SECRET=<paste the API Secret from the Dashboard>
SESSION_SECRET=<generate one: openssl rand -hex 32>
```

#### PHP · development

getenv() doesn't read .env files by itself: set them in your server (`SetEnv` in Apache, `env[]` in PHP-FPM), or load the .env with `vlucas/phpdotenv`.

**.env**

```dotenv
APP_URL=http://localhost:8080
BLOCKAUTH_API_KEY=your_api_key
BLOCKAUTH_API_SECRET=<paste the API Secret from the Dashboard>
```

#### PHP · production

Set them in your server or platform (Docker, your hosting…), not in a file you upload with your code.

**Environment variables on your server**

```dotenv
APP_URL=https://your-app.com
BLOCKAUTH_API_KEY=your_api_key
BLOCKAUTH_API_SECRET=<paste the API Secret from the Dashboard>
```

#### Python (Flask) · development

In a .env in your backend folder. `flask run` loads it if `python-dotenv` is installed; with `python app.py`, gunicorn or waitress, call `load_dotenv()` first, use `uv run --env-file .env …` or export the variables.

**.env**

```dotenv
APP_URL=http://localhost:5000
BLOCKAUTH_API_KEY=your_api_key
BLOCKAUTH_API_SECRET=<paste the API Secret from the Dashboard>
SESSION_SECRET=<generate one: openssl rand -hex 32>
```

#### Python (Flask) · production

Set them in your server or platform (Docker, your hosting…), not in a file you upload with your code.

**Environment variables on your server**

```dotenv
APP_URL=https://your-app.com
BLOCKAUTH_API_KEY=your_api_key
BLOCKAUTH_API_SECRET=<paste the API Secret from the Dashboard>
SESSION_SECRET=<generate one: openssl rand -hex 32>
```

#### Python (FastAPI) · development

In a .env in your backend folder. Start uvicorn with `--env-file .env` (needs `python-dotenv` installed) or, with uv, `uv run --env-file .env uvicorn …`, or export the variables.

**.env**

```dotenv
APP_URL=http://localhost:8000
BLOCKAUTH_API_KEY=your_api_key
BLOCKAUTH_API_SECRET=<paste the API Secret from the Dashboard>
SESSION_SECRET=<generate one: openssl rand -hex 32>
```

#### Python (FastAPI) · production

Set them in your server or platform (Docker, your hosting…), not in a file you upload with your code.

**Environment variables on your server**

```dotenv
APP_URL=https://your-app.com
BLOCKAUTH_API_KEY=your_api_key
BLOCKAUTH_API_SECRET=<paste the API Secret from the Dashboard>
SESSION_SECRET=<generate one: openssl rand -hex 32>
```

#### .NET · development

The public values go in `appsettings.json`. The secret never goes in a file you commit: in development use `user-secrets`, in production an environment variable.

**appsettings.json**

```json
{
  "APP_URL": "http://localhost:5000",
  "BLOCKAUTH_API_KEY": "your_api_key"
}
```

**Terminal, in the project folder (development only)**

```bash
dotnet user-secrets init
dotnet user-secrets set "BLOCKAUTH_API_SECRET" "<paste the API Secret from the Dashboard>"
```

#### .NET · production

Set them in your server or platform (Docker, your hosting…), not in a file you upload with your code.

**appsettings.json**

```json
{
  "APP_URL": "https://your-app.com",
  "BLOCKAUTH_API_KEY": "your_api_key"
}
```

**Environment variable on your server (never in a repo file)**

```dotenv
BLOCKAUTH_API_SECRET=<paste the API Secret from the Dashboard>
```

> **Placeholders in this code:**
>
> - Replace the API Secret placeholder with your API Secret, copied straight from the Dashboard. Never paste it on this site.
> - Replace the SESSION\_SECRET placeholder with a random value generated on your computer: `openssl rand -hex 32`.
> - Replace `your_api_key` with your API Key, or fill in your data in the SDK Quickstart and it is filled in for you.
> - Replace `https://your-app.com` with your app URL, or fill in your data in the SDK Quickstart and it is filled in for you.

## Install the client

Install the Block-Auth client for your language, in your project folder (the one with its `package.json`, `composer.json`, `requirements.txt` or `.csproj`). It gives you `AuthCodeClient`, the same in every language.

**Node.js · Terminal · in your project folder**

```bash
npm install @block-auth.io/node express express-session
```

**PHP · Terminal · in your project folder**

```bash
composer require blockauth/sdk
```

**Python · Terminal · in your project folder**

```bash
pip install blockauth-sdk flask
```

**.NET · Terminal · in your project folder**

```bash
dotnet add package BlockAuth.Sdk
```

### Without the Block-Auth client (optional)

**If you installed the client above, skip this section**: the client already makes these calls for you in the next steps. Use it only if you can’t or don’t want to install any package. In that case, instead of the client, your login route and your callback call the API with plain HTTP, from any language. Send the **SHA-256 hash (hex)** of your `apiSecret`, never the secret itself: compute it on your computer with `printf '%s' "$BLOCKAUTH_API_SECRET" | sha256sum | cut -d' ' -f1`.

Your login route asks for a link and your callback redeems the code:

**Get the login link · Terminal · to try it**

```bash
curl -X POST https://wss.block-auth.io/api/auth/authorize \
  -H 'Content-Type: application/json' \
  -d '{
    "apiKey": "your_api_key",
    "apiSecret": "sha256_hex_of_your_api_secret",
    "redirectUri": "https://your-app.com/blockauth/callback",
    "state": "random_value_kept_in_the_session"
  }'
```

**Redeem the code · Terminal · to try it**

```bash
curl -X POST https://wss.block-auth.io/api/auth/token \
  -H 'Content-Type: application/json' \
  -d '{
    "apiKey": "your_api_key",
    "apiSecret": "sha256_hex_of_your_api_secret",
    "code": "code_from_the_callback",
    "redirectUri": "https://your-app.com/blockauth/callback"
  }'
```

> **Placeholders in this code:**
>
> - Replace the `sha256_…` value with the SHA-256 hash (hex) of your API Secret. Compute it on your computer, never on a web page.
> - Replace `your_api_key` with your API Key, or fill in your data in the SDK Quickstart and it is filled in for you.
> - Replace `https://your-app.com` with your app URL, or fill in your data in the SDK Quickstart and it is filled in for you.

Every response is `{ "success": true, "message": … }`; for `/api/auth/token`, `message` holds `address`, `did` and `roles`. To verify a webhook, compute `v1=` + HMAC-SHA256 of `timestamp.body` (the `X-BlockAuth-Timestamp` header, a dot and the raw body), keyed with the SHA-256 hash of your `apiSecret`, and compare it with `X-BlockAuth-Signature`. All the parameters and errors are in [User login](/api-user-login.md).

Next step: [Login](/sdk-integration-server-login.md)
