Insufficient permission exception from BigQuery API

I get an “Insufficient permissions” exception from BigQuery when I try to list the datasets in my project (via service.Datasets.List). What should I do to grant this permission? Full source code 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
+4
source share
1 answer

Turns out I didn't have the key line of the template:

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

I really don't understand what this is doing (the documentation is terribly sparse), but adding this line solves the problem.

+3
source

All Articles