“如何修复”;“身份验证握手失败”;尝试使用Golang/Cloud函数在google firestore中存储数据时
我正在使用Google Cloud函数进行Go/Golang(Http触发器)和tyring,以便在Firestore数据库中存储数据。但是,客户机总是失败 “rpc错误:code=Unavailable desc=所有子网络都处于暂时失败状态,最新连接错误:连接错误:desc=传输:身份验证握手失败:超过上下文截止日期” 数据库是通过Firebase管理控制台()按照以下规则创建的“如何修复”;“身份验证握手失败”;尝试使用Golang/Cloud函数在google firestore中存储数据时,go,firebase-realtime-database,google-cloud-firestore,google-cloud-functions,Go,Firebase Realtime Database,Google Cloud Firestore,Google Cloud Functions,我正在使用Google Cloud函数进行Go/Golang(Http触发器)和tyring,以便在Firestore数据库中存储数据。但是,客户机总是失败 “rpc错误:code=Unavailable desc=所有子网络都处于暂时失败状态,最新连接错误:连接错误:desc=传输:身份验证握手失败:超过上下文截止日期” 数据库是通过Firebase管理控制台()按照以下规则创建的 service cloud.firestore { match /databases/{database}/
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if false;
}
}
}
我在“现收现付”计划中工作
“重要”进口
导入(
“上下文”
...
firebase“firebase.google.com/go”
)
保存的代码
func保存值(注册共享.注册)错误{
ctx:=context.Background()
conf:=&firebase.Config{ProjectID:ProjectID}
app,err:=firebase.NewApp(ctx,conf)
如果错误!=零{
返回fmt.Errorf(“创建客户端%v时出错”,err)
}
客户端,错误:=app.Firestore(ctx)
如果错误!=零{
返回fmt.Errorf(“创建客户端%v失败”,错误)
}
延迟客户端。关闭()
t:=时间。现在()
documentName:=“注册”
_,err=client.Collection(“registration”).Doc(documentName).Set(ctx,registration)
如果错误!=零{
返回fmt.Errorf(“添加注册失败:%v”,错误)
}
归零
}
go.mod文件:
module githib.com/kkoehler/<my-project>
require (
cloud.google.com/go v0.37.4
firebase.google.com/go v3.7.0+incompatible
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/sirupsen/logrus v1.4.1
golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a // indirect
google.golang.org/api v0.3.2 // indirect
)
模块githib.com/kkoehler/
要求(
cloud.google.com/go v0.37.4
firebase.google.com/go v3.7.0+不兼容
github.com/KyleBanks/depth v1.2.1//间接
github.com/sirupsen/logrus v1.4.1
golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a//间接
google.golang.org/api v0.3.2//
)
最后一次调用(client.Collection(“registration”).Doc(documentName).Set(ctx,registration)
)失败,并显示给定的错误消息
有没有办法获得关于这个问题的更多信息?
有什么建议吗
谢谢,
克里斯蒂安
解决方案
这是firestore的权限问题。如果我更改firestore数据库的权限,它将正常工作。
暂时更改为为为所有人编写;-)