<p>编辑:有关预授权的服务器应用程序,请参见编辑。在</p>
<p>您要查找的是PyDrive中的<a href="https://googledrive.github.io/PyDrive/docs/build/html/pydrive.html#pydrive.auth.GoogleAuth.CommandLineAuth" rel="nofollow noreferrer">^{<cd1>}</a>。在</p>
<p>您的代码应该如下所示:</p>
<pre><code>from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
ga = GoogleAuth()
ga.CommandLineAuth() # This line in your code currently calls LocalWebserverAuth()
drive = GoogleDrive(self.ga)
# etc.
</code></pre>
<p>当您在服务器上运行脚本时,它会要求您将链接复制粘贴到本地浏览器中。一旦你用一个特定的帐户登录,你会得到一个看似随机的字母和数字串。把这个字符串粘贴到你的控制台,你应该可以开始了。在</p>
<p>由于您可能不希望每次脚本运行时都这样做,所以考虑向您的项目添加一个<code>settings.yaml</code>文件,该文件允许您保存登录凭据。有关如何设置的详细信息可以在<a href="https://googledrive.github.io/PyDrive/docs/build/html/oauth.html#sample-settings-yaml" rel="nofollow noreferrer">docs</a>中找到。在</p>
<hr/>
<p><strong>编辑:</strong>如果要将PyDrive脚本分发到任何服务器,而无需进一步验证,则必须:</p>
<ol>
<li>下载<code>client_secret_xxxxx.json</code></li>
<li>将<code>settings.yaml</code>文件添加到您的项目中,请参见<a href="https://github.com/googledrive/PyDrive/blob/master/pydrive/test/settings/test2.yaml" rel="nofollow noreferrer">template</a>。确保设置了<code>save_credentials_file:</code>,例如<code>creds.json</code></li>
<li>将<code>client-secret</code>等信息从<code>client_secret_xxxx.json</code>复制到<code>settings.yaml</code>文件中。在</li>
<li>在我们的开发机器上完成身份验证过程-现在您的文件夹中应该有一个包含凭据的额外文件(例如<code>creds.json</code>)</li>
<li>将包含a)原始脚本、b)<code>settings.yaml</code>文件和c)生成的<code>creds.json</code>文件的整个目录复制到远程计算机。确保相对路径不会改变。在</li>
<li>利润?在</li>
</ol>
<p>注意:googledriveapi有附加的API调用限制,在100秒内阻止超过100次调用。在</p>