gpt4 book ai didi

f# - BigQuery API 权限不足异常

转载 作者:行者123 更新时间:2023-12-04 23:06:45 25 4
gpt4 key购买 nike

尝试列出项目中的数据集(通过 service.Datasets.List)时,我从 BigQuery 收到“权限不足”异常。我需要做什么才能授予此权限?完整的 F# 源代码:

open System
open System.IO
open System.Threading

open Google.Apis.Auth.OAuth2
open Google.Apis.Bigquery.v2
open Google.Apis.Bigquery.v2.Data
open Google.Apis.Services

let private service =
let credential =
let secrets =
use stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read)
GoogleClientSecrets.Load(stream).Secrets
let task =
GoogleWebAuthorizationBroker.AuthorizeAsync(
secrets,
[| BigqueryService.Scope.Bigquery |],
"user",
CancellationToken.None)
printfn "Authenticating"
task
|> Async.AwaitTask
|> Async.RunSynchronously
let initializer = new BaseClientService.Initializer(HttpClientInitializer = credential)
new BigqueryService(initializer)

[<EntryPoint>]
let main argv =
let projectId = "{MyProjectId}"
let list = service.Datasets.List(projectId).Execute()
for dataset in list.Datasets do
printfn "%A" dataset.FriendlyName
0

最佳答案

事实证明,我错过了样板代码的关键行:

GoogleWebAuthorizationBroker.Folder <- "Tasks.Auth.Store";

我不太明白这是做什么的(文档非常稀疏),但是添加这一行解决了问题。

关于f# - BigQuery API 权限不足异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27234203/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com