> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.itential.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.itential.com/_mcp/server.

# Encoding and encrypting token request values

> How to use the encode and encrypt schema flags to base64-encode or AES-encrypt individual field values in a token request.

This system requires that specific fields in the token request body be encoded or encrypted before being sent. This example demonstrates both techniques applied to different fields: the username is base64-encoded, and the password is AES-encrypted.

Both techniques operate on the field's **value only** — the key name is never encoded or encrypted.

## Configuration

This scenario requires only a change to the request schema file. For background on these schema flags, see [Encode a field value](/adapters/configure/schemas/field-definitions) and [Encrypt a field value](/adapters/configure/schemas/field-definitions).

### Request schema

* Set `encode: true` on the `username` field to base64-encode its value before the request is sent.
* Add an `encrypt` object with `type` and `key` to the `password` field to AES-encrypt its value. Encryption only applies when a key is provided. Currently, AES is the only supported encryption type.

```json
{
  "$id": "oAuthTokenRequest.json",
  "type": "object",
  "schema": "http://json-schema.org/draft-07/schema#",
  "translate": true,
  "dynamicfields": true,
  "properties": {
    "ph_request_type": {
      "type": "string",
      "description": "type of request (internal to adapter)",
      "default": "getToken",
      "enum": ["getToken"],
      "external_name": "ph_request_type"
    },
    "username": {
      "type": "string",
      "description": "username to log in with",
      "encode": true,
      "external_name": "username"
    },
    "password": {
      "type": "string",
      "description": "password to log in with",
      "encrypt": {
        "type": "AES",
        "key": "myspecialkey"
      },
      "external_name": "password"
    }
  },
  "definitions": {}
}
```