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

Data management API 403 Error: This user could not be authenticated

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
409 Views, 3 Replies

Data management API 403 Error: This user could not be authenticated

Hi All,

 

I am writing a python script that automates the process of getting drawing files from a project. Currently I am able to access but hub, list of projects and folders through the script. However, whenever I try to search the folder for all drawing files I get a 403 Error saying the users could not be authenticated. 

I am using 2 legged authentication to get the access token. I added data:search to the scope as required by the api but still get the same error. I have search everywhere online and nothing seems to work. Please is there anyone that can help. 

I have attached the access token  function, the search function and an image of the result.

 

def getAccessToken():
    url = "https://developer.api.autodesk.com/authentication/v1/authenticate"
    payload = 'client_id={client_id}&client_secret={client_secret}&grant_type=client_credentials&scope=code%3Aall%20data%3Awrite%20data%3Aread%20data%3Asearch%20bucket%3Acreate%20bucket%3Adelete%20bucket%3Aread%20account%3Aread'
    headers = {
        'Content-Type': 'application/x-www-form-urlencoded',
    }
    response = requests.request("POST", url, headers=headers, data=payload)
    json_data = json.loads(response.text)
    return json_data["access_token"]


token = getAccessToken()

 

 

def getDrawingFiles(folderId):
    url = f"https://developer.api.autodesk.com/data/v1/projects/{project_id}/folders/{folderId}/search"
    payload = {}
    headers = {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Authorization': f'Bearer {token}',
        'x-user-id': userId,
        'x-ads-region':'emea'
    }
    response = requests.request("GET", url, headers=headers, data=payload)
    json_data = json.loads(response.text)
    print(json_data)


getDrawingFiles('urn:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)

 

 

Capture.PNG

 Please can anyone offer some advice?

 

 

 

 

 

3 REPLIES 3
Message 2 of 4
mikako_harada
in reply to: Anonymous

I assume you are using BIM 360 Docs based BIM 360 (not BIM 360 Team which is A360 based).
If so, could you try removing the app in account admin >> custom integration tab, (click “Detail” >> remove app),

and go through the integration process again? 

We had a case in the past where re-provisioning helped.  So could you give it a try?  


Mikako Harada
Developer Technical Services
Message 3 of 4
Anonymous
in reply to: mikako_harada

Hi,

 

Thankyou for your response. I tried that but it still returns the same error message. It seems like the problem might be with the data:search included in the scope because the api works for all requests requiring data:read.

 

Please let me know if anything else comes to mind. 

 

Kind regards,

Timothy

Message 4 of 4
mikako_harada
in reply to: Anonymous

Re-reading the documentation, 

https://forge.autodesk.com/en/docs/data/v2/reference/http/projects-project_id-folders-folder_id-sear...

 

I noticed that it says: 
"Authentication Context:  user context required"

"Authorization:  Must be Bearer <token>, where <token> is obtained via a three-legged OAuth flow."

 

It does not says, x-user-id as possible header parameter.  So looks like it only supports 3-legged authentication.

 

You will need to implement a logic to recursively look into each folder: 

https://forge.autodesk.com/en/docs/data/v2/reference/http/projects-project_id-folders-folder_id-cont...

 


Mikako Harada
Developer Technical Services

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

Post to forums  

Autodesk Design & Make Report