API PUT Error: Full authentication is required to access this resource

Hello,
I am trying to execute a PUT API call to update a DOMO variable in a workflow. I have the variable's URL and I have the secret token needed to authorize the call (per DOMO's documentation), however I am still getting the following error:
{"status":401,"statusReason":"Unauthorized","path":"/api/query/v1/functions/template/146","message":"Full authentication is required to access this resource"
Below is the URL format and the bit of code I am using for the PUT function
URL: https://mycompany.domo.com/api/query/v1/functions/template/XXX
CODE:
def update_date(): url = 'https://mycompany.domo.com/api/query/v1/functions/template/XXX' auth_token = "XXX" headers = { "Authorization": f"Bearer {auth_token}", "Content-Type": "application/json" } data = { "id": ###, "name": "Booked as of", "owner": ###, "locked": "false", "global": "true", "certificationStatus": "EXPIRED", "expression": "DATE('2025-05-15')", # Field I am trying to update "checkSum": "XXX", "links": [], "legacyId": "calculation_XXX", "lastModified": ###, "created": ###, "aggregated": "false", "analytic": "false", "nonAggregatedColumns": [], "dataType": "DATE", "status": "VALID", "cacheWindow": "non_dynamic", "columnPositions": [], "functions": [] "DATE" [], "functionTemplateDependencies": [], "archived": "false", "hidden": "false", "variable": "true" } response = requests.put(url, json=data, headers=headers) if response.status_code == 200: return print(response.text) else: print(response.text)
Does anyone have any clue on what I am missing here?
Answers
-
Domo has different types of tokens and they are easy to confuse. Make sure you are using the correct type of token. It looks like you are trying to use a client secret directly in the header. You use a client ID and secret to generate a token from Domo's token endpoint and then use the token.
# Define Domo API credentials
domo_client_id = 'XXXXX' # Domo client ID
domo_client_secret = 'XXXXX' # Domo client secret
domo_dataset_id = "XXXXX"
# Initialize Domo SDK
domo = Domo(domo_client_id, domo_client_secret, api_host='api.domo.com')
# Get authentication token from the Domo API
def get_auth_token():
payload = {
"client_id": client_id,
"client_secret": client_secret,
"grant_type": "password",
"username": username,
"password": password
}
headers = {"Content-Type": "application/json"}
response = requests.post(token_url, json=payload, headers=headers)
if response.status_code == 200:
print("Auth token successfully retrieved.")
return response.json().get("access_token")
else:
print(f"Failed to retrieve token: {response.status_code}, {response.text}")
return None** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **0 -
Hey there, thank you for the response! You are right in saying that DOMO's tokens can be hard to understand. I ended up deducing that the root of the issue was related to having SSO enabled for my account. Thus, I simply needed to simply create a access token for the user I wanted to access the API through and leverage the below bit of code in the headers:
headers = {'x-domo-developer-token': developer_token}
where 'developer_token' is the alias given to the access token I created in my DOMO instance.
0 -
I don't think it's related to SSO. So you went to Admin > Authentication > Access Tokens, created a token and used it in the statement as an 'x-domo-developer-token' and its now working?
** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **0 -
Correct.
0
Categories
- All Categories
- 2K Product Ideas
- 2K Ideas Exchange
- 1.6K Connect
- 1.3K Connectors
- 308 Workbench
- 7 Cloud Amplifier
- 10 Federated
- 3.8K Transform
- 660 Datasets
- 117 SQL DataFlows
- 2.2K Magic ETL
- 818 Beast Mode
- 3.3K Visualize
- 2.5K Charting
- 84 App Studio
- 46 Variables
- 781 Automate
- 191 Apps
- 483 APIs & Domo Developer
- 84 Workflows
- 23 Code Engine
- 43 AI and Machine Learning
- 22 AI Chat
- 3 AI Projects and Models
- 18 Jupyter Workspaces
- 408 Distribute
- 116 Domo Everywhere
- 281 Scheduled Reports
- 11 Software Integrations
- 146 Manage
- 142 Governance & Security
- 8 Domo Community Gallery
- 49 Product Releases
- 13 Domo University
- 5.4K Community Forums
- 41 Getting Started
- 31 Community Member Introductions
- 115 Community Announcements
- 4.8K Archive