【发布时间】:2019-06-26 08:12:04
【问题描述】:
我正在尝试使用 Ruby SDK 创建动态链接。我相信我做的一切都是对的,但我得到了一个
Google::Apis::ServerError: 服务器错误
创建 URL 时
您能帮我弄清楚我遗漏了什么/做错了什么,或者这是 Google 的问题吗?
假设我已经生成了请求适当范围的 Oauth 凭据,我正在这样做
request = ::Google::Apis::FirebasedynamiclinksV1::CreateManagedShortLinkRequest.new(
dynamic_link_info: ::Google::Apis::FirebasedynamiclinksV1::DynamicLinkInfo.new(
domain_uri_prefix: Rails.application.secrets.firebase_dynamic_link_prefix,
link: campaign.linkedin_url,
),
suffix: ::Google::Apis::FirebasedynamiclinksV1::Suffix.new(
option: 'SHORT',
),
# name: "Linkedin acquisition URL of #{camp.utm_campaign_name} for #{camp.contractor.name} <#{camp.contractor.email}>",
name: "Test of generation",
)
# => <Google::Apis::FirebasedynamiclinksV1::CreateManagedShortLinkRequest:0x000021618baa88
# @dynamic_link_info=#<Google::Apis::FirebasedynamiclinksV1::DynamicLinkInfo:0x000021618bad80
# @domain_uri_prefix="https://example.page.link",
# @link="https://www.example.com/?invitation_code=example&signup=example&utm_campaign=example&utm_medium=example&utm_source=example">,
# @name="Test of generation",
# @suffix=#<Google::Apis::FirebasedynamiclinksV1::Suffix:0x000021618babf0
# @option="SHORT">
# >
link_service.create_managed_short_link(request)
def link_service
@link_service ||= begin
svc = ::Google::Apis::FirebasedynamiclinksV1::FirebaseDynamicLinksService.new
svc.authorization = oauth_service.credentials
svc
end
end
我知道 OAuth 范围似乎像以前一样工作
Google::Apis::ClientError: 禁止:请求的身份验证范围不足。
但我在增加 OAuth 范围以涵盖 firebase 后修复了它。此外,我的请求似乎是正确的,因为当我尝试省略其中一个参数(如 name)时,我遇到了适当的验证错误,例如
Google::Apis::ClientError: badRequest: Created Managed Dynamic Link 必须有名称
我唯一的线索是,create_managed_short_link 实际上需要更多参数。在上面给出的示例中,我还用 example 替换了我们真正的 firebase 前缀,但我确实拥有我正在使用的真正的 firebase 前缀,并且直接从 Firebase 前端控制台生成链接确实有效。
我已将我的 google sdk 更新为最新版本
- google-api-client-0.30.3
【问题讨论】:
标签: firebase google-api firebase-dynamic-links google-api-ruby-client