michelson / dante2

A complete rewrite of dante editor in draft-js
https://michelson.github.io/dante2/
Other
912 stars 122 forks source link

Embedly API Key not found #16

Closed Bodacious closed 7 years ago

Bodacious commented 7 years ago

I've set up an account with Embed.ly and added their API key to my application.

if $("[data-editor-content]").length > 0

  $data = $("[data-editor-content]").data()

  window.editor = new Dante
    el: "editor"
    api_key: $data.apiKey
    read_only: !$data.editable
    content: $("[data-editor-content]").data("editor-content")
    upload_url: $data.uploadUrl
    data_storage:
      failure_handler: -> console.log("Failure")
      success_handler: -> console.log("Success")
      interval: 1000
      url: $data.dataStorageUrl
      method: "PATCH"
    xhr:
      before_handler:  ->
        console.log("Before xhr")
      success_handler: ->
        console.log("Success xhr")
      error_handler: ->
        console.log("Error xhr")

  editor.render()

When I inspect my editor I can see the API key in the options

console.log(editor.options.api_key) # => "[mykey"]

But when I try to embed a URL, I see this error message

Invalid `key` provided: undefined. To find your key, log into https://app.embed.ly -> API.

And the same thing is reported in my console.

[Error] Failed to load resource: the server responded with a status of 401 (Unauthorized) (extract, line 0)      https://api.embed.ly/1/extract?key=undefined&url=https://vimeo.com/197412946&scheme=https

Any ideas?

reimertz commented 7 years ago

Have you white-listed your domain?

michelson commented 7 years ago

uhm that's odd as you can see the default api key for testing works fine

Bodacious commented 7 years ago

Yep

screenshot 2017-01-05 12 43 16
reimertz commented 7 years ago

@bodacious I had to add /* to make it work on all urls.

Bodacious commented 7 years ago

Yep, that was the solution. It's strange that they require that.