2016-04-24 103 views
0

我们正在从谷歌的BigQuery以下错误而刀片:错误在授权过程

**号的OAuth2凭证发现,开始授权过程**

== Platform == 
    CPython:2.7.5:Windows-2008ServerR2-6.1.7601-SP1 
== bq version == 
    v2.0.17 
== Command line == 
    ['C:\\LogsReceiverService\\bq-script.py', 'load', '--nosync', '--credential_file=C:\\LogsReceiverService\\.bigquery.v2.token', '--source_format=NEWLINE_DELIMITED_JSON', '--project_id=playscape-proj', '--max_bad_records=99999', 'PROD_DATASET.CLIENT_LOGS_20160424', 'D:\\GameConsoleLogs\\Logs_BigQuery\\GameConsoleClientLog.log.1.gz'] 
== UTC timestamp == 
    2016-04-24 13:32:53 
== Error trace == 
    File "build\bdist.win32\egg\bq.py", line 783, in RunSafely 
    return_value = self.RunWithArgs(*args, **kwds) 
    File "build\bdist.win32\egg\bq.py", line 999, in RunWithArgs 
    client = Client.Get() 
    File "build\bdist.win32\egg\bq.py", line 604, in Get 
    cls.client = Client.Create() 
    File "build\bdist.win32\egg\bq.py", line 584, in Create 
    credentials = _GetCredentialsFromFlags() 
    File "build\bdist.win32\egg\bq.py", line 390, in _GetCredentialsFromFlags 
    credentials = credentials_getter(storage) 
    File "build\bdist.win32\egg\bq.py", line 330, in _GetCredentialsFromOAuthFlow 
    credentials = oauth2client.tools.run(flow, storage) 
    File "build\bdist.win32\egg\oauth2client\util.py", line 132, in positional_wrapper 
    return wrapped(*args, **kwargs) 
    File "build\bdist.win32\egg\oauth2client\old_run.py", line 149, in run 
    code = raw_input('Enter verification code: ').strip() 
======================================== 

该消息还包括一个链接令牌密钥,但我们不确定我们应该如何处理它。

你能帮忙吗?谢谢

回答

0

运行bq(或任何gcloud操作)时,客户端需要为运行此操作的用户提供OAuth凭据。通常这些客户首次使用时会要求提供凭证,但听起来您的情况并非如此。 (或者可能凭证文件已损坏?)

要删除bq客户端的凭证文件副本,请运行bq init --delete_credentials

要尝试重新验证,请使用bq init。请注意,如果您正在使用gcloud客户端与其他Google服务通话,bq.py将优先使用这些凭据,因此您可能需要在删除本地BigQuery凭据后运行gcloud auth login --enable-gdrive-access。 (--enable-grdive-access是可选的,但它可以通过Google表格使用新的BigQuery联合查询功能。您可能会也可能不需要此功能。)

凭证的另一种选择:如果要将这些操作作为脚本运行人为干预,您可以使用服务帐户凭证,以便将这些操作作为另一种身份而不是与您的个人凭证一起完成。有两种选择这里取决于你要运行脚本:

  • 您可以在项目中创建一个服务帐户和下载的凭据,然后使用--service_account--service_account_private_key_file--service_account_private_key_password标志运行操作作为服务帐户而不是您的个人身份。
  • 如果您在GCE实例内运行bq,您可以指定单个标志--user_gce_service_account,并且bq客户端将从GCE容器中加载凭证。
+0

当我运行'bq init --delete_credentials'时,我得到了这个错误信息'The'init'命令不再需要与Cloud SDK'。 –