Why is Forge returning code 403 for Data Connector API This clientId is not authorized to perform the operation

Viewed 15

Why is Forge returning code 403 for Data Connector API This clientId is not authorized to perform the operation. The token call comes back correctly but I get 403 on the gethubs {"warnings":[{"Id":null,"HttpStatusCode":"403","ErrorCode":"BIM360DM_ERROR","Title":"Unable to get hubs from BIM360DM EMEA.","Detail":"You don't have permission to access this API","AboutLink":null,"Source":null,"meta":null}]}}

And getcon as well "{"detail":"This clientId is not authorized to perform the operation.","status":403,"type":"error","title":"Forbidden","id":69852363,"errors":[{"detail":"This clientId is not authorized to perform the operation.","title":"Forbidden","type":"error"}]}"

These are the calls from App script using, what I think is, 3-legged code grant.

function getToken() {
var formData = {
'client_id': 'ClientID',
'client_secret': 'ClientSecret',
'grant_type': 'client_credentials',
'scope': 'user-profile:read user:read user:write viewables:read 
data:create data:read data:write data:search bucket:read     bucket:create 
bucket:update code:all account:read account:write',
'prompt':'login'
};  var response = 

  UrlFetchApp.fetch('https://developer.api.autodesk.com/authentication/v1/a uthenticate', {
method: 'POST',
payload: formData
});  
var token = JSON.parse(response.getContentText());  
console.log(token);
return token.access_token;  
}

function getHubs() {
var token = getToken();  
console.log(token);     
var header = {"Authorization" : "Bearer " + token};  
console.log(header); 

var options = {    
"method" : "get",    
"headers" : header    
};  

var response = UrlFetchApp.fetch('https://developer.api.autodesk.com/project/v1/hubs',     options);

var hubs = JSON.parse(response.getContentText());  
console.log(JSON.stringify(hubs));
}
function getDConn() {
  var token = getToken();  
  console.log(token);     
  var header = {"Authorization" : "Bearer " + token,"Content-Type": "application/json" };  
  console.log(header); 

  var options = {    
  "method" : "post",    
      "headers" : header,  
      "description": "AccountExtract",
      "isActive": true,
      "scheduleInterval": "ONE_TIME",
      "reoccuringInterval": null,
      "effectiveFrom": "2022-10-06T10:00:00.106Z",
      "effectiveTo":  "2022-10-06T10:00:00.106Z",
      "serviceGroups": "locations",
      "callbackUrl": null,
      "sendEmail": true,
      "projectId": null
    };  

    //Google Account ID
      var response = UrlFetchApp.fetch('https://developer.api.autodesk.com/data-      connector/v1/accounts/ACCOUNTID/requests', options);

    var hubs = JSON.parse(response.getContentText());  
    console.log(JSON.stringify(hubs));
0 Answers
Related