使用ColdFusion的Google驱动API

使用ColdFusion的Google驱动API,coldfusion,google-drive-api,Coldfusion,Google Drive Api,我开始使用ColdFusion开发GoogleDriveAPI,我一直坚持使用ColdFusion上传文件。我已经完成了新项目的注册,获得了客户和客户机密,我成功地获得了accessToken,但不知何故,我无法将文件上传到谷歌硬盘上 Here is the code to get the code and accesstoken <cfoutput> <cfset request.oauthSettings = { scope = "https://www.g

我开始使用ColdFusion开发GoogleDriveAPI,我一直坚持使用ColdFusion上传文件。我已经完成了新项目的注册,获得了客户和客户机密,我成功地获得了accessToken,但不知何故,我无法将文件上传到谷歌硬盘上

Here is the code to get the code and accesstoken

<cfoutput>  
  <cfset request.oauthSettings = {
   scope = "https://www.googleapis.com/auth/drive",      client_id = "clientid",
   client_secret = "clientsecret",
   redirect_uri = "link"}
  />      
  <!--- create login url --->
  <cfset loginURL = "https://accounts.google.com/o/oauth2/auth?scope=" 
   & request.oauthSettings["scope"]
   & "&redirect_uri=" & request.oauthSettings["redirect_uri"]
   & "&response_type=code&client_id=" & request.oauthSettings["client_id"]
   & "&access_type=offline"
  />

  <a href="#loginURL#">Login with Google account that has access to analytics</a>

  <cfif isDefined("URL.code") AND URL.code NEQ "access_denied">     
    <cfhttp url="#arguments.gaOauthUrl#" method="post">
     <cfhttpparam name="code" type="formField" value="#arguments.code#">
     <cfhttpparam name="client_id" type="formField" value="clientid">
     <cfhttpparam name="client_secret" type="formField" value="clientsecret">
     <cfhttpparam name="redirect_uri" type="formField" value="link">
     <cfhttpparam name="grant_type" type="formField" value="authorization_code">
    </cfhttp>       
  </cfif>    
</cfoutput>
我使用下面的代码来上传文件,我知道我必须传递更多的参数以使其正确,但我不知道这些参数是什么

<cfhttp url="https://www.googleapis.com/upload/drive/v2/files?uploadType=media" method="post">
  <cfhttpparam name="Content-Type" type="formField" value="text/plain">
  <cfhttpparam name="Authorization" type="formField" value="#session.ga_accessToken#">            
</cfhttp>

我试图在谷歌文档中找到答案,但运气不好;没有关于ColdFusion的文档。如果有人对此区域有所了解,请告诉我其他参数。

您没有正确设置授权标头。应该是

Authorization:  Bearer ya29.AHES6ZRosLBEnyGGH9EysIrAB7Z

这里列出了所有参数:嗨,Duncan,谢谢你的帮助,但是ColdFusion没有库,我只需要知道如何传递文件的路径。我想上传word文件。任何帮助都将不胜感激。提前感谢我认为您只需要为“body”添加一个参数,如下:-请参阅感谢您提供了这些重要信息。我在带有access_令牌的授权中添加了承载文本,但仍然需要一个参数,即我要上载的文件的路径,但我不知道如何传递它。我已经用Bear和accesstoken更改了授权码。