Warning: This article is now 5 years old! It is highly likely that this information is out of date and the author will have completely forgotten about it. Please take care when following any guidance to ensure you have up-to-date recommendations.
To generate a basic authentication header from a username and password in Code Stream you could use a CI task and execute echo -n username:password | base64 in the shell then export the result for use later on. A more repeatable way is to create a Custom Integration that takes the two inputs, and returns the encoded header as an output.
To create the Custom Integration:
- Create a new Custom Integration named “Create Basic Authentication Header”
- Select the Runtime - the examples below are
shellandpython3respectively - Replace the placeholder code with the example from below
- Save and version the Custom Integration, ensuring you eanble the “Release Version” toggle
To use the Custom Integration in a pipeline:
- Configure the Host (you’ll need a Docker endpoint configured for this) and Builder image URL settings in the Workspace tab of your pipeline (e.g.
python:latest) - Add a new Custom task, to your Stage, select the “Create Basic Authentication Header” integration and configure the inputs
- Use the tasks
output.propertiesto refer to the header value in your later tasks - e.g. I’m using${Stage0.Create Auth Header.output.properties.basicAuthHeader}to refer to the output in a REST task below:
Below are the shell and a Python3 examples, in the YAML format to paste into your custom integration:
---
runtime: shell
code: |
export basicAuthHeader=$(echo -n $username:$password | base64)
inputProperties: # Enter fields for input section of a task
# Username input
- name: 'username'
type: text
title: 'Username'
placeHolder: 'Enter basic authentication usename'
required: true
bindable: true
# Password input
- name: 'password'
type: password
title: 'Password'
placeHolder: 'Enter basic authentication password'
defaultValue: ''
required: true
bindable: true
outputProperties:
- name: basicAuthHeader
type: label
title: Basic Authentication Header---
runtime: "python3"
code: |
from base64 import b64encode
from context import getInput, setOutput
username = getInput('username')
password = getInput('password')
usernameAndPassword = b64encode(bytes(f'{username}:{password}',encoding='ascii')).decode('ascii')
setOutput('basicAuthHeader', "Basic "+usernameAndPassword)
inputProperties: # Enter fields for input section of a task
# Username input
- name: 'username'
type: text
title: 'Username'
placeHolder: 'Enter basic authentication usename'
required: true
bindable: true
# Password input
- name: 'password'
type: password
title: 'Password'
placeHolder: 'Enter basic authentication password'
defaultValue: ''
required: true
bindable: true
outputProperties:
- name: basicAuthHeader
type: label
title: Basic Authentication Header

