我正在使用BigQuery的命令行工具將數據加載到BigQuery中。使用BigQuery命令行工具時出現OAuth 2.0不一致錯誤
private void RunShellCmd(string cmd, string args)
{
ProcessStartInfo start = new ProcessStartInfo
{
FileName = cmd,
Arguments = args,
UseShellExecute = false,
RedirectStandardOutput = true
};
using (Process process = Process.Start(start))
{
using (StreamReader reader = process.StandardOutput)
{
string result = reader.ReadToEnd();
if (OnMessage != null)
{
OnMessage(result);
}
}
}
}
凡CMD是對BQ腳本工具和路徑ARGS是:
我用下面的方法運行通過C#程序BQ工具 負荷--nosync --credential_file = _CRED_PATH_ --source_format = NEWLINE_DELIMITED_JSON --project_id = _PROJECT_ID_ _TABLE_URI_ _DATA_FILE_
從shell執行精確的命令時,它可以很好地工作。 然而,通過C#程序中,我發現了以下的輸出:
Welcome to BigQuery! This script will walk you through the process of initializing your .bigqueryrc configuration file.
First, we need to set up your credentials if they do not already exist.
******************************************************************
** No OAuth2 credentials found, beginning authorization process **
******************************************************************
Go to the following link in your browser:
https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fbigquery&redirect_uri=...
Enter verification code: You have encountered a bug in the BigQuery CLI. Google engineers monitor and answer questions on Stack Overflow, with the tag google-bigquery: http://stackoverflow.com/questions/ask?tags=google-bigquery Please include a brief description of the steps that led to this issue, as well as the following information:
========================================
== Platform == CPython:2.7.5:Windows-2008ServerR2-6.1.7601-SP1
== bq version == v2.0.16
== Command line == ['C:\\Python27\\Scripts\\bq-script.py', 'load', '--nosync', '--credential_file=C:\\Users\\Administrator\\.bigquery.v2.token', '--source_format=NEWLINE_DELIMITED_JSON', '--project_id=_PROJECT_ID_',
>'_TABLE_URI_', '_DATA_FILE_PATH_']
== UTC timestamp == 2013-10-20 05:52:59
== 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 2082, 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()
========================================
Unexpected exception in init operation: EOF when reading a line
Successfully started load _TABLE_URI_
奇怪的是,該命令的實際工作,並正確地加載數據(也被最終輸出線證明)。 但由於某種原因,它前面有一個OAUTH 2.0錯誤。
有沒有人遇到過這樣的事情? 任何想法可能會導致它?
謝謝!
因爲它仍處於測試階段。一旦它完全發佈,我會做一個切換... – Shakkalakka
儘管C#客戶端正處於測試階段,但我認爲你可能會更好地使用它。它表示它可能會在發佈之前更改,但是線上API不應以反向不兼容的方式更改。所以如果你現在下載C#客戶端,它應該繼續工作,直到api更改,這應該有1年+棄用週期。如果C#客戶端發生更改,它可能需要更改代碼,但您應該至少有一年才能更新到更高版本。 –
不幸的是,目前還不可能。 :/ 雖然檢查了您添加的建議,但我發現它可能與權限有關。 當我以管理員身份(而不是本地系統服務)運行上述服務時,問題消失。 雖然我添加了--credential_file標誌和--bigqueryrc標誌,並將它們指向一個完全控制給所有人的文件夾,這很奇怪。 難道這個工具試圖將證書或其他文件寫入另一個文件夾嗎? – Shakkalakka