No matter what I do. I can't connect to the Bim 360 api(I have code + errors).

No matter what I do. I can't connect to the Bim 360 api(I have code + errors).

Anonymous
Not applicable
3,476 Views
10 Replies
Message 1 of 11

No matter what I do. I can't connect to the Bim 360 api(I have code + errors).

Anonymous
Not applicable

Ok so I said it in the title. I have an app. I have a custom integration set up. I am account admin. I've used two and three legged auth. I've tried everything. I just want to use the get hubs command but it won't work. Here is my code(it's php and I forgot to mention I've also used the program postman and no luck, they have the same error):

 

<?php 
$url = $_SERVER['REQUEST_URI'];
$code = substr($url, 25);

//Get auth code(three leg)

$headers[] = 'Content-type: application/x-www-form-urlencoded';
$process = curl_init();
curl_setopt($process, CURLOPT_HTTPHEADER, $headers); 
curl_setopt($process, CURLOPT_URL, "https://developer.api.autodesk.com/authentication/v1/gettoken");
curl_setopt($process, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($process, CURLOPT_POSTFIELDS, "client_id=IAl4aVyefelxPaxxxxxxxxxxx&client_secret=letsNotShowYouThis&grant_type=authorization_code&code=" . strval($code) . "&redirect_uri=http://localhost/siteForge/home.php&scope=bucket:create%20bucket:read%20data:read%20data:write%20bucket:delete%20viewables:read%20account:read%20account:write");
curl_setopt($process, CURLOPT_POST, 1);

$result = curl_exec($process);
curl_close($process);

//get three leg access code

for($i = 19; $i < strlen($result); $i++){ //Get access code(the manual way)
	if($result[$i] === '"'){
		$access_code_three = substr($result, 17, $i-17);
		break;
	}
}

//Get auth code(two leg)

$headers = array();
$headers[] = 'Content-type: application/x-www-form-urlencoded';
$process = curl_init();
curl_setopt($process, CURLOPT_HTTPHEADER, $headers); 
curl_setopt($process, CURLOPT_URL, "https://developer.api.autodesk.com/authentication/v1/authenticate");
curl_setopt($process, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($process, CURLOPT_POSTFIELDS, "client_id=IAl4aVyefelxPaxxxxxxxxx&client_secret=letsNotShowYouThis&grant_type=client_credentials&scope=data:read data:write data:create");
curl_setopt($process, CURLOPT_POST, 1);

$result = curl_exec($process);
curl_close($process);

//get two leg access code

for($i = 19; $i < strlen($result); $i++){ //Get access code(the manual way)
	if($result[$i] === '"'){
		$access_code_two = substr($result, 17, $i-17);
		break;
	}
}

//BIM 360 Document viewer

$process = curl_init();

$headers = array();
$headers[] = "Authorization: Bearer " . $access_code_two;
curl_setopt($process, CURLOPT_URL, "https://developer.api.autodesk.com/project/v1/hubs");
curl_setopt($process, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($process, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($process, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($process);
curl_close ($process);
print($result)

//End of "BIM 360 Document viewer"

?>

aaaaand the error:

	{"jsonapi":{"version":"1.0"},"errors":[{"status":"403","code":"BIM360DM_ERROR","title":"Unable to get hubs from BIM360DM US.","detail":"You don't have permission to access this API"},{"status":"403","code":"BIM360DM_ERROR","title":"Unable to get hubs from BIM360DM EMEA.","detail":"You don't have permission to access this API"}]} 

Ask me if you need screenshots of the my admin account info to make sure I've set everything up correctly on the server side.

0 Likes
3,477 Views
10 Replies
Replies (10)
Message 2 of 11

mikako_harada
Community Manager
Community Manager

You are trying to access BIM 360 Docs?  If so, these might help: 

 

https://fieldofviewblog.wordpress.com/2017/01/19/bim-360-activating-api-access-to-docs/

 

https://fieldofviewblog.wordpress.com/2017/08/18/no-custom-integrations-tab/

 

(note: there is some naming change.  if you see "Apps & Integration", please read it as "Custom Integration".)

 

After checking those,  if you still see a problem, let us know.  


Mikako Harada
Developer Technical Services
0 Likes
Message 3 of 11

Anonymous
Not applicable

I have sent my email and the custom integration tab is available.

0 Likes
Message 4 of 11

Anonymous
Not applicable

I tried making a custom integration but it still does not work. Same error.

0 Likes
Message 5 of 11

mikako_harada
Community Manager
Community Manager

A couple of suggestions to trouble shoot:

 

1. try using a tool like postman first.  If it works, then the logic should be correct. You can focus on the error in a code.

2. Try creating personal A360 account. And test using there.  Make sure you use 3-legged for A360 as A360 only accept 3-legged token. You can use postman to get a 3-legged token for testing purpose. The same hubs call should work with both hubs. BIM 360 Docs has extra step to provision. So this way, you can tell if the issue is provisioning part or something else. 

3. sometimes copy and pasting client ID in the custom integration page is not done correctly (like type error, or has extra blank space). Try provisioning app again in BIM 360 Account Admin by creating a new one to make sure you entered client id correctly.   


Mikako Harada
Developer Technical Services
0 Likes
Message 6 of 11

Anonymous
Not applicable

No luck. Can you show me what your postman request would look like for the two legged auth token. I just need to see how you format your body.

0 Likes
Message 7 of 11

mikako_harada
Community Manager
Community Manager

Here is how my postman looks like: 

 

postman 2-leg.PNGpostman hubs.PNG

 

I hope this leads you to find a problematic spot.  If this still does not help, we will need to do desktop sharing or something. 


Mikako Harada
Developer Technical Services
0 Likes
Message 8 of 11

Anonymous
Not applicable
{
    "jsonapi": {
        "version": "1.0"
    },
    "links": {
        "self": {
            "href": "https://developer.api.autodesk.com/project/v1/hubs"
        }
    },
    "data": [
        {
            "type": "hubs",
            "id": "a.XXXXXXXXXXXXXXXXXXXX",
            "attributes": {
                "name": "My Name :P",
                "extension": {
                    "type": "hubs:autodesk.core:Hub",
                    "version": "1.0",
                    "schema": {
                        "href": "https://developer.api.autodesk.com/schema/v1/versions/hubs:autodesk.core:Hub-1.0"
                    },
                    "data": {}
                }
            },
            "links": {
                "self": {
                    "href": "https://developer.api.autodesk.com/project/v1/hubs/a.XXXXXXXXXXXXXXXXXXXXXXX"
                }
            },
            "relationships": {
                "projects": {
                    "links": {
                        "related": {
                            "href": "https://developer.api.autodesk.com/project/v1/hubs/a.XXXXXXXXXXXXXX/projects"
                        }
                    }
                }
            }
        }
    ],
    "meta": {
        "warnings": [
            {
                "Id": null,
                "HttpStatusCode": "403",
                "ErrorCode": "BIM360DM_ERROR",
                "Title": "Unable to get hubs from BIM360DM US.",
                "Detail": "You don't have permission to access this API",
                "AboutLink": null,
                "Source": [],
                "meta": []
            },
            {
                "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": [],
                "meta": []
            }
        ]
    }
}

Ok so I'm making progress with the three legged token but it's the wrong hub... And the error is still there. Desktop sharing would be fantastic too.

0 Likes
Message 9 of 11

Anonymous
Not applicable
Could you make this any more convoluted. Also, could you please write official docs on the matter and link them inside the "Developer" section under Documentation? The only thing listed for the app to work (https://developer.autodesk.com/en/docs/oauth/v2/tutorials/create-app/) is the app creation, not this completely obviated authorization process... Sending e-mail now, hope this works. PS: I'm trying this in Postman first, and it's quite sad to see an error when you follow every `curl` in the examples to the letter....
0 Likes
Message 10 of 11

Anonymous
Not applicable

 


@Anonymous wrote:
Could you make this any more convoluted. Also, could you please write official docs on the matter and link them inside the "Developer" section under Documentation? The only thing listed for the app to work (https://developer.autodesk.com/en/docs/oauth/v2/tutorials/create-app/) is the app creation, not this completely obviated authorization process... Sending e-mail now, hope this works. PS: I'm trying this in Postman first, and it's quite sad to see an error when you follow every `curl` in the examples to the letter....

 

I understand Learning a new API's authentication process can be frustrating but there's no need to be rude about it, especially to someone who was genuinely trying to help you.

 

For anyone who runs into this issue here's what fixed it on my end:

 

This response is of status 200 indicating that you have completed the OAuth correctly. What's missing is the performing of setting up your app as approved with a BIM360 Admin for the hub you are trying to access

 

Here's a very helpful and incredibly well documented guide for doing this.

0 Likes
Message 11 of 11

dwilliamsTQTQL
Community Visitor
Community Visitor

Many apps use oauth, and it's not rocket science, and I can call many APIs from many systems. But getting these 403 errors on the hub call is very frustrating. It seems all the docs and videos are missing something very very important.  Getting a token is fine!  Getting that hub response is absolutely horrid.  

0 Likes