Autodesk Forge Access Token时出现错误请求

时间:2017-04-02 04:43:53

标签: autodesk-forge

我正在尝试执行两条腿的身份验证 - 尝试执行以下命令以获取访问令牌

$ /cygdrive/c/xampp/apache/bin/curl.exe -v  
       'https://developer.api.autodesk.com/authentication/v1/authenticate' -X 'POST'  -H 'Content-Type: application/x-www-form-urlencoded'   -d  
        'client_id=****clientid*****&  client_secret=****clientsecret******&  grant_type=client_credentials&  scope=data:read'  

我收到以下回复:

        Note: Unnecessary use of -X or --request, POST is already inferred.         
           % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                       Dload  Upload   Total   Spent    Left  Speed
          0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*            Trying 34.251.61.88...
        * Connected to developer.api.autodesk.com (34.251.61.88) port 443 (#0)
        * Cipher selection: 
        ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
        * successfully set certificate verify locations:
        *   CAfile: C:\xampp\apache\bin\curl-ca-bundle.crt
        CApath: none
        * TLSv1.2 (OUT), TLS Unknown, Certificate Status (22):
        } [5 bytes data]
        * TLSv1.2 (OUT), TLS handshake, Client hello (1):
         } [512 bytes data]
        0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     
         0* TLSv1.2 (IN), TLS handshake, Server hello (2):
        { [89 bytes data]
        * TLSv1.2 (IN), TLS handshake, Certificate (11):
        { [3086 bytes data]
        * TLSv1.2 (IN), TLS handshake, Server key exchange (12):
         { [333 bytes data]
         * TLSv1.2 (IN), TLS handshake, Server finished (14):
         { [4 bytes data]
         * TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
         } [70 bytes data]
       * TLSv1.2 (OUT), TLS change cipher, Client hello (1):
         } [1 bytes data]
         * TLSv1.2 (OUT), TLS handshake, Finished (20):
        } [16 bytes data]
       * TLSv1.2 (IN), TLS change cipher, Client hello (1):
       { [1 bytes data]
       * TLSv1.2 (IN), TLS handshake, Finished (20):
       { [16 bytes data]
      * SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
      * Server certificate:
       *        subject: jurisdictionC=US; jurisdictionST=Delaware; 
      businessCategory=Private Organization; serialNumber=2401504; C=US; 
      postalCode=94903; ST=California; L=San Rafael; street=111 McInnis Parkway; 
      O=Autodesk, Inc.; OU=PDG; CN=developer.api.autodesk.com
      *        start date: May 17 00:00:00 2016 GMT
      *        expire date: May 17 23:59:59 2017 GMT
     *        subjectAltName: developer.api.autodesk.com matched
      *        issuer: C=US; O=Symantec Corporation; OU=Symantec Trust Network; 
     CN=Symantec Class 3 Extended Validation SHA256 SSL CA
     *        SSL certificate verify ok.
        0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     
       0} [5 bytes data]
       > POST /authentication/v1/authenticate HTTP/1.1
       > Host: developer.api.autodesk.com
       > User-Agent: curl/7.47.1
       > Accept: */*
       > Content-Type: application/x-www-form-urlencoded
       > Content-Length: 125
>
       } [125 bytes data]
       * upload completely sent off: 125 out of 125 bytes
      { [5 bytes data]
      < HTTP/1.1 400 Bad Request
       < Content-Type: application/json
       < Date: Sat, 01 Apr 2017 09:13:17 GMT
       < Server: Apigee Router
     < Content-Length: 221
      < Connection: keep-alive
     <
       { [221 bytes data]
         100   346  100   221  100   125    114     64  0:00:01  0:00:01 --:--:-
         -   115{"developerMessage":"The required parameter(s) 
            client_secret,grant_type not present in the 
           request","userMessage":"","errorCode":"AUTH-008","more 
      info":"http://developer.api.autodesk.com/documentation/v1/errors/AUTH-
        008"}
        * Connection #0 to host developer.api.autodesk.com left intact

为什么有&lt;输出中的HTTP / 1.1 400 Bad Request?

2 个答案:

答案 0 :(得分:0)

请确保删除请求中的空格,特别是在&amp;

之后的-d参数
$ /cygdrive/c/xampp/apache/bin/curl.exe 
 -v 'https://developer.api.autodesk.com/authentication/v1/authenticate' 
 -X 'POST'-H 'Content-Type: application/x-www-form-urlencoded' 
 -d 'client_id=***&client_secret=***&grant_type=client_credentials&scope=data:read'  

答案 1 :(得分:0)

我使用cURL和JQ(JSON处理器)创建了一个帖子,它可以帮助您完成未来的开发。这篇文章是关于使用cURL的2腿认证。

https://forge.autodesk.com/blog/tutorial-using-curl-2-legged-authentication-model-translation