1
votes

I am trying to create a dynamic link using the Ruby SDK. I believe I have everything right, but I'm getting a

Google::Apis::ServerError: Server error

When creating the URL

Could you help me figure out what I'm missing/doing wrong or if this is a Google issue ?

Assuming I have generates Oauth credentials requesting the appropriate scopes, I am doing

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

I know OAuth scopes seem to be working as previously I was getting

Google::Apis::ClientError: forbidden: Request had insufficient authentication scopes.

But I fixed it after increasing OAuth scopes to cover firebase. Also, my request seems correct, as when I try to omit one of the parameters (like the name) I'm getting appropriate validation errors like

Google::Apis::ClientError: badRequest: Created Managed Dynamic Link must have a name

My only clue, is that the create_managed_short_link actually takes more parameters. In the example given above, I also have substituted our real firebase prefix by example but I do own the real firebase prefix I am using, and link generation directly from the Firebase frontend console actually works.

I've updates my google sdk to the most recent version up to date - google-api-client-0.30.3

1

1 Answers

0
votes

Unfortunately generating managed short links through the REST API is not currently supported.

As stated here by someone who works(ed) in the dynamic links team itself.

For now we can only use CreateShortDynamicLinkRequest, however this endpoint does not allow to specify a custom_suffix (i.e. https://example.com/my-custom-suffix)