Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Bitbucket Autoscaler Runners on Kubernetes: 401 Unauthorized Error with API Tokens

Higor Oliveira September 16, 2025

Has anyone successfully deployed Bitbucket Auto Runners on K8s using API tokens? Any advice on troubleshooting this 401 error would be greatly appreciated – especially if it's a common gotcha with token scopes or endpoint compatibility. It works with app password, however app password will be deprecated. The error:

Unauthorized. Check your bitbucket credentials. Status code 401: {"type": "error", "error": { "message": "Token is invalid, expired, or not supported for this endpoint." }}

I'm using this links:

base64 encode: https://support.atlassian.com/bitbucket-cloud/docs/autoscaler-for-runners-on-kubernetes/

I'm following this link: https://community.atlassian.com/forums/Bitbucket-questions/Bitbucket-runners-autoscaler-doesn-t-accept-API-Token/qaq-p/3084658

My kustomization.yaml:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../base

configMapGenerator:
- name: runners-autoscaler-config
files:
- runners_config.yaml
options:
disableNameSuffixHash: true

runners_config.yaml.
namespace: bitbucket-runner-control-plane

commonLabels:
app.kubernetes.io/part-of: runners-autoscaler

images:
- name: bitbucketpipelines/runners-autoscaler
newTag: 3.9.0

patches:
- target:
version: v1
kind: Secret
name: runner-bitbucket-credentials

patch: |-
- op: add
path: /data/atlassianAccountEmail
value: "my_account_email_in_base64"
- op: add
path: /data/atlassianApiToken
value: "my_api_token_in_base64"

- target:
version: v1
kind: Deployment
labelSelector: "inject=runners-autoscaler-envs"
patch: |-
- op: replace
path: /spec/template/spec/containers/0/env
value:
- name: ATLASSIAN_ACCOUNT_EMAIL
valueFrom:
secretKeyRef:
key: atlassianAccountEmail
name: runner-bitbucket-credentials
- name: ATLASSIAN_API_TOKEN
valueFrom:
secretKeyRef:
key: atlassianApiToken
name: runner-bitbucket-credentials



I created this api key (the last accessed field was changed when I tried to run the autoscaler):

Screenshot from 2025-09-16 15-45-48.png

1 answer

1 accepted

0 votes
Answer accepted
Higor Oliveira September 18, 2025

As suggested here https://community.atlassian.com/forums/Bitbucket-questions/Bitbucket-runners-autoscaler-doesn-t-accept-API-Token/qaq-p/3084658?utm_source=atlcomm&utm_medium=email&utm_campaign=mentions_reply&utm_content=topic, creating an API token and select the scopes admin and runner solved the problem, I was using the plain Create API Token option.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin Site Admin
TAGS
AUG Leaders

Atlassian Community Events