第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

cloudtasks.CreateTask 失?。篳缺少 IAM 權(quán)限

cloudtasks.CreateTask 失?。篳缺少 IAM 權(quán)限

Go
慕標(biāo)琳琳 2022-05-18 14:35:16
我正在關(guān)注創(chuàng)建 HTTP 目標(biāo)任務(wù)指南。當(dāng)我運(yùn)行下面發(fā)布的代碼時(shí),出現(xiàn)此錯(cuò)誤:cloudtasks.CreateTask: rpc error: code = PermissionDenied desc = The principal (user or service account)lacks IAM permission "cloudtasks.tasks.create" for the resource "projects/my_project/locations/europe-west1/queues/my_queue" (or the resource may not exist).我已使用 登錄gcloud auth login my@email.com。my@email.com 具有由我的自定義云任務(wù)角色設(shè)置的以下權(quán)限:cloudtasks.locations.getcloudtasks.locations.listcloudtasks.queues.getcloudtasks.queues.listcloudtasks.tasks.createcloudtasks.tasks.deletecloudtasks.tasks.fullViewcloudtasks.tasks.getcloudtasks.tasks.listcloudtasks.tasks.run我不明白。我還應(yīng)該檢查什么?main.go// Run `PROJECT_ID=my_project QUEUE_ID=my_queue go run main.go`package mainimport (  "context"  "fmt"  "os"  cloudtasks "cloud.google.com/go/cloudtasks/apiv2"  taskspb "google.golang.org/genproto/googleapis/cloud/tasks/v2")var (  locationID = "europe-west1"  url        = "example.com/callback"  message    = "testing")func main() {  projectID := os.Getenv("PROJECT_ID")  queueID := os.Getenv("QUEUE_ID")  task, err := createHTTPTask(projectID, locationID, queueID, url, message)  if err != nil {    fmt.Println(err)  }  fmt.Println(task)}// createHTTPTask creates a new task with a HTTP target then adds it to a Queue.func createHTTPTask(projectID, locationID, queueID, url, message string) (*taskspb.Task, error) {  // Create a new Cloud Tasks client instance.  // See https://godoc.org/cloud.google.com/go/cloudtasks/apiv2  ctx := context.Background()  client, err := cloudtasks.NewClient(ctx)  if err != nil {    return nil, fmt.Errorf("NewClient: %v", err)  }  // Build the Task queue path.  queuePath := fmt.Sprintf("projects/%s/locations/%s/queues/%s", projectID, locationID, queueID)  // Build the Task payload.  // https://godoc.org/google.golang.org/genproto/googleapis/cloud/tasks/v2#CreateTaskRequest  req := &taskspb.CreateTaskRequest{    Parent: queuePath,        },      },    },  }Cloud Tasks API已啟用。
查看完整描述

2 回答

?
子衿沉夜

TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超3個(gè)贊

在過(guò)去的幾天里,我一直遇到同樣的問(wèn)題,并想通了。我用來(lái)創(chuàng)建 API 客戶端和創(chuàng)建任務(wù)的庫(kù)使用的憑據(jù)與我預(yù)期的不同。

對(duì)于那些使用“應(yīng)用程序默認(rèn)憑據(jù)”或至少讓客戶端自動(dòng)查找憑據(jù)的用戶,請(qǐng)查看此頁(yè)面:https ://cloud.google.com/docs/authentication/production#finding_credentials_automatically

我創(chuàng)建了一個(gè)具有所有正確角色的服務(wù)帳戶,并假設(shè) API 客戶端正在使用該服務(wù)帳戶。原來(lái)我沒(méi)有傳入密鑰文件,因此它使用的是“應(yīng)用程序默認(rèn)憑據(jù)”。對(duì)于我的用例,“應(yīng)用程序默認(rèn)憑據(jù)”指的是 App Engine 默認(rèn)服務(wù)帳戶。當(dāng)我為 API 客戶端提供我的自定義服務(wù)帳戶的密鑰文件時(shí),它起作用了。


查看完整回答
反對(duì) 回復(fù) 2022-05-18
?
慕姐8265434

TA貢獻(xiàn)1813條經(jīng)驗(yàn) 獲得超2個(gè)贊

應(yīng)用程序默認(rèn)憑據(jù) (ADC) 提供了一種獲取用于調(diào)用 Google API 的憑據(jù)的方法。gcloud auth application-default 命令組允許您管理計(jì)算機(jī)上用于本地應(yīng)用程序開發(fā)的活動(dòng)憑據(jù)。

使用以下命令獲取用于 ADC 的新用戶憑據(jù):

gcloud auth application-default login


查看完整回答
反對(duì) 回復(fù) 2022-05-18
  • 2 回答
  • 0 關(guān)注
  • 145 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)