【发布时间】:2023-03-23 10:29:01
【问题描述】:
我正在使用 google api ruby client 向日历添加 webhook,但我遇到了 Google::Apis::ClientError: pushWebhookBadDomain。
我已经设置了一个 ngrok 实例并在网站管理员工具上对其进行了验证,以便我可以将其作为允许的域添加到处理所有日历身份验证等的项目中。我找不到对该特定错误的任何引用所以我想知道使用 ngrok 是否有什么时髦之处,以及是否有更好的方法可以在本地测试 webhook。
这是电话(为清楚起见而精简)以防我做任何愚蠢的事情:
require 'google/apis/calendar_v3'
client = Google::Apis::CalendarV3::CalendarService.new
authorization = Signet::OAuth2::Client.new(
:authorization_uri =>
'https://accounts.google.com/o/oauth2/auth',
:token_credential_uri =>
'https://accounts.google.com/o/oauth2/token'
)
authorization.client_id = ENV['GOOGLE_CLIENT_ID']
authorization.client_secret = ENV['GOOGLE_CLIENT_SECRET']
authorization.grant_type = 'refresh_token'
authorization.refresh_token = refresh_token
authorization.fetch_access_token!
client.authorization = authorization
channel = Google::Apis::CalendarV3::Channel.new(address: success_callback_url, id: channel_id, type: "web_hook")
binding.pry
webhook = client.watch_event('primary', channel, single_events: true, time_min: Time.now.iso8601)
【问题讨论】:
-
您是否按照这里提到的所有步骤developers.google.com/google-apps/calendar/v3/push?hl=en 。您的 webhook 回调 URL 是 HTTPS 还是 HTTP?你也可以在推送通知操场上测试pushnotificationsplayground.appspot.com
-
是的,所有这些都遵循了,这些游乐场网站的主要问题是它没有使用我的应用程序,而且我遇到的问题与允许的网站和其他应用程序有关-具体属性我没有得到有用的信息。
-
我的主要好奇心是,如果这一切都归结为 ngrok 的 ssl 证书不好(谷歌认为),以及其他人是否有更好的方法在本地进行设置
标签: ruby-on-rails google-calendar-api google-api-client google-api-ruby-client