The to-base64 operation encodes a value into Base64, a way of writing anything as plain ASCII text. You need it when an API asks for it, and almost the only time it asks is for authentication.
How it works
Value: hello Result: aGVsbG8=
Value: 12345 Result: MTIzNDU=
Value: {"id":1} Result: eyJpZCI6MX0=
An empty value gives an empty result.
Basic authentication
This is the common use, and it takes three steps because the header carries one encoded string rather than two values.
- A Set node joins the credentials with a colon between them, for example
{client_id}:{client_secret}, into a field of its own. - A Modify Field step runs to-base64 on it.
- The header on the request reads
Authorization: Basic {auth}.
The prefix is Basic , with a trailing space. Not Bearer , which goes in front of a token that is already usable as it stands and never gets encoded. Mixing the two up is the most frequent reason an authentication header is refused.
See prefix and HTTP request.
It is not encryption
Base64 hides nothing. Anyone who sees the encoded string can decode it in a second, and from-base64 will do it for you.
It exists to make arbitrary data safe to put in a text field, not to protect it. Treat an encoded secret exactly as carefully as you would treat the secret itself.
When not to use it
Only encode when the other side specifically asks for it. Sending Base64 to an API that expected plain text gives you a rejection with an unhelpful message, because to them the value simply looks wrong.
Bear in mind it also makes the data about a third larger, which matters if you are ever moving something big.
The other direction
To decode, use from-base64.
Reference
See PHP: base64_encode.

