小编buz*_*j99的帖子

使用 JSON 对象而不是 JSON 文件进行 Google API 身份验证 - Node.js

我目前正在使用以下代码作为服务帐户进行身份验证:

const auth = new google.auth.GoogleAuth({
    keyFile: "<path/to/credentials>",
    scopes: [<scopes>],
});
Run Code Online (Sandbox Code Playgroud)

有没有办法使用包含与 keyFile 相同内容的 JSON 对象进行身份验证?例如,做这样的事情:

const credentials = {
  "type": ...,
  "project_id": ...,
  "private_key_id": ...,
  "private_key": ...,
  "client_email": ...,
  "client_id": ...,
  "auth_uri": ...,
  "token_uri": ...,
  "auth_provider_x509_cert_url": ...,
  "client_x509_cert_url": ...
}

const auth = new google.auth.GoogleAuth({
  keyFile: credentials,
  scopes: [<scopes>],
});
Run Code Online (Sandbox Code Playgroud)

javascript json google-api google-authentication node.js

6
推荐指数
1
解决办法
2777
查看次数

Swift NWConnection - 接收失败,出现错误“流上没有可用消息”

我目前正在开发一个 iOS 应用程序,我需要连接到另一台设备。使用 TCP 成功建立了 NWConnection,我可以从远程设备接收一条(并且只有一条)消息并立即收到错误消息。连接被取消(我猜是由错误引起的)。控制台日志显示:

Hello World.
[connection] nw_flow_add_read_request [C1 <ip and port of remote device> ready channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, ipv6, dns)] already delivered final read, cannot accept read requests
[connection] nw_read_request_report [C1] Receive failed with error "No message available on STREAM"
error
Run Code Online (Sandbox Code Playgroud)

我的代码如下所示:

Hello World.
[connection] nw_flow_add_read_request [C1 <ip and port of remote device> ready channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, ipv6, dns)] already delivered final read, cannot accept …
Run Code Online (Sandbox Code Playgroud)

networking tcp stream swift

5
推荐指数
0
解决办法
405
查看次数