I have encountered a similar issue when using google.golang.org/api/cloudfunctions/v1,
the first problem with 403 error I had, was due to using auth client
with presigned Generate Upload URL, using bare http client helped
httpClient := http.DefaultClient
data, err := ioutil.ReadAll(reader)
if err != nil {
return err
}
request, err := http.NewRequest("PUT", uploadURL, bytes.NewReader(data))
if err != nil {
return err
}
request.Header.Set("content-type", "application/zip")
request.Header.Set("x-goog-content-length-range", "0,104857600")
request.Header.Set("Content-Length", fmt.Sprintf("%d", len(data)))
response, err := httpClient.Do(request)
if err != nil {
return err
}
Another issue I saw with 404 was when I was using location as region as opposed to the fully qualified name presented in the below snippet
var location = 'projects/${projectID}/locations/${region}'
projectService := cloudfunctions.NewProjectsLocationsFunctionsService(ctxClient.service)
createCall := projectService.Create(location, request.CloudFunction)
createCall.Context(ctxClient.Context())
return createCall.Do()
h
You can also check golang cloud functions google.golang.org/api/cloudfunctions/v1 API usage in this project:
Cloud function service