0

I am using the Laravel backend on my platform. I have been able to get a three legged token, but when I try to get a list of hubs for the user, the response is completely different from the example.

    $client = new Client(); //GuzzleHttp\Client     
    $response = $client->request('GET', 'https://developer.api.autodesk.com/project/v1/hubs', [
        'headers' => [
            'Authorization' => 'Bearer '.$obj->access_token
            'x-user-id' => $userObj->userId
        ]
    ]);

I have confirmed that the user ID and token are sent fine. However, the response that I get is nothing like the example.

object(GuzzleHttp\Psr7\Response)#611 (6) {
  ["reasonPhrase":"GuzzleHttp\Psr7\Response":private]=>string(2) "OK"
  ["statusCode":"GuzzleHttp\Psr7\Response":private]=>int(200)
  ["headers":"GuzzleHttp\Psr7\Response":private]=>array(11) {
  ["Content-Type"]=>
array(1) {
  [0]=>
  string(24) "application/vnd.api+json"
}
["Date"]=>
array(1) {
  [0]=>
  string(29) "Tue, 26 Mar 2019 19:55:02 GMT"
}
["Referrer-Policy"]=>
array(1) {
  [0]=>
  string(24) "origin-when-cross-origin"
}
["Server"]=>
array(1) {
  [0]=>
  string(8) "forge-dm"
}
["Strict-Transport-Security"]=>
array(1) {
  [0]=>
  string(35) "max-age=31536000; includeSubDomains"
}
["X-Content-Type-Options"]=>
array(1) {
  [0]=>
  string(7) "nosniff"
}
["X-Frame-Options"]=>
array(1) {
  [0]=>
  string(4) "DENY"
}
["X-Request-Id"]=>
array(1) {
  [0]=>
  string(36) "b747247f-b93b-4557-ae11-821b76fc8bba"
}
["X-XSS-Protection"]=>
array(1) {
  [0]=>
  string(13) "1; mode=block"
}
["Content-Length"]=>
array(1) {
  [0]=>
  string(4) "1087"
}
["Connection"]=>
array(1) {
  [0]=>
  string(10) "keep-alive"
}
}

["headerNames":"GuzzleHttp\Psr7\Response":private]=>array(11) {
["content-type"]=>string(12) "Content-Type"
["date"]=>string(4) "Date"
["referrer-policy"]=>string(15) "Referrer-Policy"
["server"]=>string(6) "Server"
["strict-transport-security"]=>string(25) "Strict-Transport-Security"
["x-content-type-options"]=>string(22) "X-Content-Type-Options"
["x-frame-options"]=>string(15) "X-Frame-Options"
["x-request-id"]=>string(12) "X-Request-Id"
["x-xss-protection"]=>string(16) "X-XSS-Protection"
["content-length"]=>string(14) "Content-Length"
["connection"]=>string(10) "Connection"
}
  ["protocol":"GuzzleHttp\Psr7\Response":private]=>string(3) "1.1"
  ["stream":"GuzzleHttp\Psr7\Response":private]=>object(GuzzleHttp\Psr7\Stream)#635 (7) {
["stream":"GuzzleHttp\Psr7\Stream":private]=>
resource(47) of type (stream)
["size":"GuzzleHttp\Psr7\Stream":private]=>
NULL
["seekable":"GuzzleHttp\Psr7\Stream":private]=>
bool(true)
["readable":"GuzzleHttp\Psr7\Stream":private]=>
bool(true)
["writable":"GuzzleHttp\Psr7\Stream":private]=>
bool(true)
["uri":"GuzzleHttp\Psr7\Stream":private]=>
string(10) "php://temp"
["customMetadata":"GuzzleHttp\Psr7\Stream":private]=>
array(0) {
    }
  }
}
Joshua Foxworth
  • 1,236
  • 1
  • 22
  • 50

1 Answers1

0

The response is different since you are using a x-user-id in your header and this should use a 2 legged token not a 3 legged one as stated in the documentation (since you already have the specific user to whom you want to get data from).

x-user-id ----- In a two-legged authentication context, the app has access to all users specified by the administrator in the SaaS integrations UI. By providing this header, the API call will be limited to act on behalf of only the user specified.

This will give you only projects for BIM 360 environment without an identifier for the difference of the type of projects. Do you have an integration already setup?

I will suggest: - 3 Legged token - GET Hubs with only the token in your header

should give you a response similar to the example. If the data you are looking for is from BIM 360, you will have to make sure custom integrations in your account have been enabled.

Jaime Rosales
  • 1,106
  • 1
  • 6
  • 8
  • I tried it without the user id and got the same response. If this is not how you get a list of files for a Fusion 360 account, how do you do that? – Joshua Foxworth Mar 26 '19 at 22:45
  • Double-checking with team, but I'm quite sure that using a **2-legged token** with **user impersonation** (x-user-id header) is only available for **BIM 360 Docs** accounts. For **Fusion Team** and **A360** you'll need a **3-legged token** – Adam Nagy Mar 27 '19 at 22:39