我尝试在本地运行 pubsub 模拟器,并使用我在 pubsub 上运行的现有服务向它发送消息。没有收到消息,我得到的只是日志中的身份验证错误。
[pubsub] Jan 22, 2017 3:43:16 PM com.google.cloud.iam.testing.v1.shared.authorization.AuthInterceptor interceptCall
[pubsub] INFO: Authentication interceptor: Header value is null
[pubsub] Jan 22, 2017 3:43:16 PM com.google.cloud.iam.testing.v1.shared.authorization.AuthInterceptor interceptCall
[pubsub] INFO: Authentication interceptor: invalid or missing token
我正在请求从 dotnet 和 nodejs 发布和拉取。
C#
var creds = GoogleCredential.GetApplicationDefaultAsync().Result;
if (creds.IsCreateScopedRequired) {
creds = creds.CreateScoped(new [] { PubsubService.Scope.Pubsub } );
}
return new PubsubService(
new BaseClientService.Initializer() {
HttpClientInitializer = creds,
ApplicationName = "My Wonderful App"
}
);
节点
var pubsub = require('@google-cloud/pubsub');
var pubsubClient = pubsub({
projectId: config.get('GCLOUD_PROJECT')
});