按照此处的指南:.NET Quickstart我能够从客户端执行示例脚本。但是,当我添加电子表格功能时,我必须包含一个额外的范围。当我这样做时,身份验证页面给了我一个错误:
“400。这是一个错误。错误:invalid_request redirect_url的参数值无效”
检查url后,似乎url参数被编码两次,除了范围之间的空间,而不是只有一次我只请求一个范围:
这是我的范围数组:
static readonly string[] s_scopesExecution = {
"https://www.googleapis.com/auth/spreadsheets",
"https://www.googleapis.com/auth/drive",
};
我传递给我的授权码
using (var stream = new FileStream(CLIENT_SECRET_FILEPATH, FileMode.Open, FileAccess.Read))
{
string credPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
credPath = Path.Combine(credPath, CRED_BASE_PATH);
//determine scopes
string[] scopes = s_scopesExecution;
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
scopes,
userName,
CancellationToken.None,
new FileDataStore(credPath, true)).Result;
}
当我将两个范围放在由空格分隔的一个字符串中时,会发生同样的错误。
这是客户端库的错误还是我做错了什么?