Hello,
I’m trying to use a python code below, generated by ChatGPT to import five “yubikey 4” tokens to a free subscription. I’m not assigning the tokens to users at this time, I’m rather intend to just add it to the tenant. I have a CSV with “secret” and “serial” columns.
import csv
import json
import requests
AUTH0_DOMAIN = 'dev-xxxxx.us.auth0.com'
MGMT_API_TOKEN = 'xxx'
STORAGE_KEY = 'yubikeys' # This key is used to store YubiKey data in Auth0 metadata
def load_yubikeys_from_csv(file_path):
yubikeys = []
with open(file_path, mode='r') as file:
csv_reader = csv.DictReader(file)
for row in csv_reader:
yubikey = {
"serial": row["serial"],
"secret": row["secret"]
}
yubikeys.append(yubikey)
return yubikeys
def store_yubikeys_in_auth0(yubikeys):
url = f'https://{AUTH0_DOMAIN}/api/v2/tenants/settings'
headers = {
'Authorization': f'Bearer {MGMT_API_TOKEN}',
'Content-Type': 'application/json'
}
# Get existing settings
response = requests.get(url, headers=headers)
if response.status_code != 200:
print(f"Failed to get tenant settings: {response.content}")
return
settings = response.json()
# Add YubiKey data to tenant settings
settings[STORAGE_KEY] = yubikeys
# Update settings with YubiKey data
response = requests.patch(url, headers=headers, data=json.dumps(settings))
if response.status_code == 200:
print("YubiKeys stored successfully in Auth0.")
else:
print(f"Failed to store YubiKeys: {response.content}")
# Load YubiKeys from CSV file
yubikeys = load_yubikeys_from_csv('C:\Data\python\yubikey\yubikey_seeds.csv')
# Store YubiKeys in Auth0
store_yubikeys_in_auth0(yubikeys)
I’m getting the following error:
Failed to store YubiKeys: b'{"statusCode":400,"error":"Bad Request","message":"Payload validation error: \'Additional properties not allowed: yubikeys,sandbox_versions_available\'.","errorCode":"invalid_body"}'
Does this imply that free tenants do not allow importing hardware tokens, or something wrong with the code?
I did notice that MFA is completely unavailable in the free subscription. Is that somehow related?
Thank you.