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

Not applicable
12-06-2017
02:28 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.