Community
Forma Developer Forum
Welcome to Autodesk Forma Developer Forum. Share your knowledge, ask questions, and explore popular Forma API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Help WIth Authentication

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
billy_awTVHNJ
192 Views, 3 Replies

Help WIth Authentication

Hi,

 

I have problems with authentication when previously I could.

Please see the screenshot.

Whenever I try and send a PUT request i get this message:
{"error":"AccessDeniedException"}
Error: 403

 

Please help... I cant create a generator.

 


import requests

# Get Token from my_requests
def get_token_from_file(file_path😞
    """Retrieve the token from a file."""
    with open(file_path, 'r') as file:
        return file.read().strip()

# Define the constants
FORMA_DOMAIN = "app.autodeskforma.eu"
PROJECT_ID = "pro_2boh3uomxl"
EXTENSION_ID = "adaccb9f-07da-4ace-bda9-378293d028b4"
TOKEN = get_token_from_file("token_genbuilding.txt")
print("Token:", TOKEN)
print("PROJ ID:", PROJECT_ID)
print("EXTENSION ID:", EXTENSION_ID)
# Formulate the generator ID and the URL
generator_id = f"urn:adsk-forma-generators:extension:{EXTENSION_ID}:{PROJECT_ID}:generator1"
url = f"https://{FORMA_DOMAIN}/api/generator-service/generators/{generator_id}?accessScope={PROJECT_ID}"

# Define the payload for the PUT request
payload = {
    "id": generator_id,
    "name": "Generate Building",
    "runners": [
        {
            "type": "extensionScript",
            "extensionId": EXTENSION_ID,
            "bundleId": "bundle1"
        }
    ],
  "schema": {
    "version": 1,
    "fields": [
     
      {
        "type": "number",
        "name": "height",
        "label": "height",
        "min": 0,
        "max": 200,
        "step": 10
      },
     
    ],
    "defaultValues": {
      "height": 100
    }
  }
}

# Define headers for the request
headers = {
    "Authorization": f"Bearer {TOKEN}",
    "Content-Type": "application/json"
}

# Make the PUT request
response = requests.put(url, json=payload, headers=headers)

# Print the response
print(response.text)

if response.status_code == 200:
    print("Generator updated successfully!")
else:
    print(f"Error: {response.status_code}")


 

 

3 REPLIES 3
Message 2 of 4

Hello @billy_awTVHNJ, and thanks for reaching out!

 

There seems to be an error related to authorization with extension credentials on our end right now. We are working on fixing the issue.

We'll come back to you once the issue has been resolved.

 

 

 

Håkon Matland
Principal Software Engineer
Message 3 of 4

tthank you so much i thought it was me....

Message 4 of 4

Hey!

The issue has been resolved.

Sorry for the disturbance!

-- Håkon Dissen

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report