Warm tip: This article is reproduced from serverfault.com, please click

List project bim 360 docs with forge api

发布于 2020-12-01 23:16:43

I'm connecting to auth forge obtaining sucessfully an access_token:

$.ajax({
      type: "POST",
      url: "https://developer.api.autodesk.com/authentication/v1/authenticate",
      data: "client_id="+client_id+"&client_secret="+client_secret+"&grant_type=client_credentials&scope=data:read",
      success: success,
      dataType: "json"
    });

then trying to list the projects from bim 360 docs, it return

{ "developerMessage":"Token does not have the privilege for this request.", "moreInfo": "https://forge.autodesk.com/en/docs/oauth/v2/developers_guide/error_handling/", "errorCode": "AUTH-010"}

I have created an app on forge and activated the "Add Custom Integration” on bim 360 docs. What am I missing?

$.ajax({
          type: "GET",
          url: "https://developer.api.autodesk.com/hq/v1/accounts/"+conta_id+"/projects",
          beforeSend: function(xhr) { 
            xhr.setRequestHeader("Authorization",  "Bearer "+token); 
          },
          processData: false,
          success: success_projects,
          error: function(){
              console.log("Cannot get data");
          },
          dataType: "json"
        });

Thanks in advance.

Questioner
Luciano
Viewed
0
Zhong Wu 2020-12-03 14:33:06

I believe this is an issue due to lack of scope, to list all the projects within your BIM 360 account by the endpoint https://forge.autodesk.com/en/docs/bim360/v1/reference/http/projects-GET/, you need "account:read" scope which I don't see that within your code. Please make sure at least to add this scope and try again.