Curl 无法使用最近使用的令牌从google drive下载文件

Curl 无法使用最近使用的令牌从google drive下载文件,curl,google-oauth,google-drive-api,Curl,Google Oauth,Google Drive Api,使用OAuth2.0作为服务器到服务器应用程序,我创建并签署了我的JWT {"iss":"xxxxx@developer.gserviceaccount.com","scope":"https://www.googleapis.com/auth/drive.file","aud":"https://accounts.google.com/o/oauth2/token","exp":1402499958,"iat":1402496358} 然后,我使用JWT请求令牌,我得到了HTTP/1.120

使用OAuth2.0作为服务器到服务器应用程序,我创建并签署了我的JWT

{"iss":"xxxxx@developer.gserviceaccount.com","scope":"https://www.googleapis.com/auth/drive.file","aud":"https://accounts.google.com/o/oauth2/token","exp":1402499958,"iat":1402496358}
然后,我使用JWT请求令牌,我得到了HTTP/1.1200 OK

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Date: Wed, 11 Jun 2014 15:02:46 GMT
Content-Disposition: attachment; filename="json.txt"; filename*=UTF-8''json.txt
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Alternate-Protocol: 443:quic
Transfer-Encoding: chunked

{
  "access_token" : "ya29.LgCMhuxHD8ivCxsAAAAwrc2qvQsi0B3bG4w-hNmWgstoyEMIsq0JxcfH0qyWIg",
  "token_type" : "Bearer",
  "expires_in" : 3600
}
curl -v -k "https://www.googleapis.com/drive/v2/files/0B7_3fthAYmhGNnVGX3owbUtITk0" -H "Authorization: Bearer ya29.LgCIqvk5z-GKKRoAAACcb2pvdgowNH6otwO7csB955WhiSjixlPo82lDSluduA"

* About to connect() to www.googleapis.com port 443 (#0)
*   Trying 173.194.67.95... connected
* Connected to www.googleapis.com (173.194.67.95) port 443 (#0)
* SSLv3, TLS handshake, Client hello (1):
  .....
* SSL connection using RC4-SHA
* Server certificate:
*        subject: C=US, ST=California, L=Mountain View, O=Google Inc,     CN=*.googleapis.com
*        start date: 2014-05-22 11:06:31 GMT
*        expire date: 2014-08-20 00:00:00 GMT
*        subjectAltName: www.googleapis.com matched
*        issuer: C=US, O=Google Inc, CN=Google Internet Authority G2
*        SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
> GET /drive/v2/files/0B7_3fthAYmhGNnVGX3owbUtITk0 HTTP/1.1
> User-Agent: curl/7.19.5 (amd64-pc-win32) libcurl/7.19.5 OpenSSL/0.9.8k
> Host: www.googleapis.com
> Accept: */*
> Authorization: Bearer ya29.LgCIqvk5z-GKKRoAAACcb2pvdgowNH6otwO7csB955WhiSjixlPo82lDSluduA
>
< HTTP/1.1 200 OK
< Expires: Wed, 11 Jun 2014 15:20:52 GMT
< Date: Wed, 11 Jun 2014 15:20:52 GMT
< Cache-Control: private, max-age=0, must-revalidate, no-transform
< ETag: "AkM7BvofPa_Jxo7Kxgh76A7i7OE/MTQwMDUwNTUxNDk4OA"
< Content-Type: application/json; charset=UTF-8
< X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
< X-XSS-Protection: 1; mode=block
< Content-Length: 2745
< Server: GSE
< Alternate-Protocol: 443:quic
<
{
 "kind": "drive#file",
 "id": "0B7_3fthAYmhGNnVGX3owbUtITk0",
 "etag": "\"AkM7BvofPa_Jxo7Kxgh76A7i7OE/MTQwMDUwNTUxNDk4OA\"",
  .......
所以我把令牌放在我的卷发请求中

curl -v -k "https://www.googleapis.com/drive/v2/files/0B7_3fthAYmhGNnVGX3owbUtITk0" -H "Authorization: Bearer ya29.LgCMhuxHD8ivCxsAAAAwrc2qvQsi0B3bG4w-hNmWgstoyEMIsq0JxcfH0qyWIg"
而响应是404找不到

* About to connect() to www.googleapis.com port 443 (#0)
*   Trying 173.194.67.95... connected
* Connected to www.googleapis.com (173.194.67.95) port 443 (#0)
* SSLv3, TLS handshake, Client hello (1):
        .......
* SSLv3, TLS handshake, Finished (20):
* SSL connection using RC4-SHA
* Server certificate:
*        subject: C=US, ST=California, L=Mountain View, O=Google Inc, CN=*.googleapis.com
*        start date: 2014-05-22 11:06:31 GMT
*        expire date: 2014-08-20 00:00:00 GMT
*        subjectAltName: www.googleapis.com matched
*        issuer: C=US, O=Google Inc, CN=Google Internet Authority G2
*        SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
> GET /drive/v2/files/0B7_3fthAYmhGNnVGX3owbUtITk0 HTTP/1.1
> User-Agent: curl/7.19.5 (amd64-pc-win32) libcurl/7.19.5 OpenSSL/0.9.8k
> Host: www.googleapis.com
> Accept: */*
> Authorization: Bearer ya29.LgCMhuxHD8ivCxsAAAAwrc2qvQsi0B3bG4w-hNmWgstoyEMIsq0JxcfH0qyWIg
>
< HTTP/1.1 404 Not Found
< Content-Type: application/json; charset=UTF-8
< Date: Wed, 11 Jun 2014 15:22:08 GMT
< Expires: Wed, 11 Jun 2014 15:22:08 GMT
< Cache-Control: private, max-age=0
< X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
< X-XSS-Protection: 1; mode=block
< Server: GSE
< Alternate-Protocol: 443:quic
< Transfer-Encoding: chunked
<
{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "notFound",
    "message": "File not found: 0B7_3fthAYmhGNnVGX3owbUtITk0"
   }
  ],
  "code": 404,
  "message": "File not found: 0B7_3fthAYmhGNnVGX3owbUtITk0"
 }
}
* Connection #0 to host www.googleapis.com left intact
* Closing connection #0
* SSLv3, TLS alert, Client hello (1):
如果我使用在OAuth2.0中获得的访问令牌,那么响应是HTTP/1.1200ok

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Date: Wed, 11 Jun 2014 15:02:46 GMT
Content-Disposition: attachment; filename="json.txt"; filename*=UTF-8''json.txt
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Alternate-Protocol: 443:quic
Transfer-Encoding: chunked

{
  "access_token" : "ya29.LgCMhuxHD8ivCxsAAAAwrc2qvQsi0B3bG4w-hNmWgstoyEMIsq0JxcfH0qyWIg",
  "token_type" : "Bearer",
  "expires_in" : 3600
}
curl -v -k "https://www.googleapis.com/drive/v2/files/0B7_3fthAYmhGNnVGX3owbUtITk0" -H "Authorization: Bearer ya29.LgCIqvk5z-GKKRoAAACcb2pvdgowNH6otwO7csB955WhiSjixlPo82lDSluduA"

* About to connect() to www.googleapis.com port 443 (#0)
*   Trying 173.194.67.95... connected
* Connected to www.googleapis.com (173.194.67.95) port 443 (#0)
* SSLv3, TLS handshake, Client hello (1):
  .....
* SSL connection using RC4-SHA
* Server certificate:
*        subject: C=US, ST=California, L=Mountain View, O=Google Inc,     CN=*.googleapis.com
*        start date: 2014-05-22 11:06:31 GMT
*        expire date: 2014-08-20 00:00:00 GMT
*        subjectAltName: www.googleapis.com matched
*        issuer: C=US, O=Google Inc, CN=Google Internet Authority G2
*        SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
> GET /drive/v2/files/0B7_3fthAYmhGNnVGX3owbUtITk0 HTTP/1.1
> User-Agent: curl/7.19.5 (amd64-pc-win32) libcurl/7.19.5 OpenSSL/0.9.8k
> Host: www.googleapis.com
> Accept: */*
> Authorization: Bearer ya29.LgCIqvk5z-GKKRoAAACcb2pvdgowNH6otwO7csB955WhiSjixlPo82lDSluduA
>
< HTTP/1.1 200 OK
< Expires: Wed, 11 Jun 2014 15:20:52 GMT
< Date: Wed, 11 Jun 2014 15:20:52 GMT
< Cache-Control: private, max-age=0, must-revalidate, no-transform
< ETag: "AkM7BvofPa_Jxo7Kxgh76A7i7OE/MTQwMDUwNTUxNDk4OA"
< Content-Type: application/json; charset=UTF-8
< X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
< X-XSS-Protection: 1; mode=block
< Content-Length: 2745
< Server: GSE
< Alternate-Protocol: 443:quic
<
{
 "kind": "drive#file",
 "id": "0B7_3fthAYmhGNnVGX3owbUtITk0",
 "etag": "\"AkM7BvofPa_Jxo7Kxgh76A7i7OE/MTQwMDUwNTUxNDk4OA\"",
  .......

我尝试了很多方法,但我不知道问题出在哪里

您是否尝试过删除/0B7_3fthAYmhGNnVGX3owbUtITk0并获取所有文件的列表?您好,我的project Google开发者控制台似乎没有与我的Google drive帐户链接。我该怎么做?服务帐户链接到它自己的帐户,而不是你的帐户。您可以与服务帐户的电子邮件地址共享文件或目录,但我没有尝试过。谢谢您的回答。我添加了服务帐户的电子邮件地址,并与我的google项目共享了我的google drive帐户的一个文件夹,但什么都没有发生,帐户之间没有链接。目标是将不使用web浏览器的应用程序中的文件上载到google drive帐户、用户帐户或服务帐户?