florinpatrascu / bolt_sips

Neo4j driver for Elixir
Apache License 2.0
256 stars 49 forks source link

Unsupported authentication token, missing key `scheme`: {user_agent='BoltSips/1.5.1'} #65

Closed daveman1010221 closed 5 years ago

daveman1010221 commented 5 years ago

Following the directions here:

https://hexdocs.pm/bolt_sips/1.5.1/readme.html

I get the following when attempting connection:

14:23:59.458 [error] Bolt.Sips.Protocol (#PID<0.276.0>) failed to connect: ** (Bolt.Sips.Internals.Error) Unsupported authentication token, missing key scheme: { user_agent='BoltSips/1.5.1' }

I've double-check my config, which is as follows:

` def application do [ applications: [:bolt_sips], mod: {Bolt.Sips.Application, []}, extra_applications: [:logger] ] end

defp deps do [ {:bolt_sips, "~> 1.5"} ] end config :bolt_sips, Bolt, hostname: 'localhost', basic_auth: [username: 'neo4j', password: 'somepasswordhere'], port: 7687 ` using: Erlang/OTP 21 [erts-10.3.4] Elixir/Mix 1.8.1 (from Brew on Mac OS High Sierra)

Connection works from the Neo4j browser. I'm not sure what to make of the error message. Any suggestions?

florinpatrascu commented 5 years ago

Hi @daveman1010221 - can you please use strings for the password and username? Try this:

config :bolt_sips, Bolt,
  hostname: 'localhost',
  basic_auth: [username: "neo4j", password: "somepasswordhere"],
  port: 7687

The hostname still needs to be a charlist, that caveat is on us, but we'll change that soon, sorry for the inconvenience.

Also, you can always use an even shorter form, for configuring the access to your server. The url, like this:

config :bolt_sips, Bolt,
  url: "bolt://neo4j:somepasswordhere@localhost:7687"

HTH

daveman1010221 commented 5 years ago

Hello! I ended up with single quotes instead of doubles by trying lots of different things, a few variants I noticed in the docs. The double quotes yields the same result: missing key scheme. I think the error is coming back through the DB engine, as I see the same message in the DB logs. It seems like it doesn't like that user_agent string?

florinpatrascu commented 5 years ago

Hmmm ... please remove the references to Bolt.Sips from your applications, in mix.exs

[
applications: [:bolt_sips], mod: {Bolt.Sips.Application, []},
extra_applications: [:logger]
]

and restore it to its original form. No need for the above, and I'll fix the docs, sorry for the confusion. Then start the driver under your app' supervision tree i.e. in your application.ex

  use Application

  def start(_type, _args) do
    import Supervisor.Spec
    # List all child processes to be supervised
    children = [
      {Bolt.Sips, Application.get_env(:bolt_sips, Bolt)},
      #  .....
    ]

    opts = [strategy: :one_for_one, name: YourApp.Supervisor]
    Supervisor.start_link(children, opts)
  end
florinpatrascu commented 5 years ago

I also updated the main README, as it was confusing.

florinpatrascu commented 5 years ago

Also, please see how I am using Bolt.Sips in this simple phoenix (1.4) app: https://github.com/florinpatrascu/bolt_movies_elixir_phoenix

just updated for using the latest version of Bolt.Sips - HTH

daveman1010221 commented 5 years ago

Victory! `iex(1)> {:ok, pid} = Bolt.Sips.start_link(url: "localhost", basic_auth: [username: "neo4j", password: "somepassword"])

{:ok, #PID<0.228.0>}

iex(2)> conn = Bolt.Sips.conn

:bolt_sips_pool

iex(3)> Bolt.Sips.query!(conn, "RETURN date({d}) AS d", %{d: ~D[2019-02-04]})

[%{"d" => ~D[2019-02-04]}]`

I can see now what the problem was... For some reason, the config was not getting passed, which obviously causes the auth to fail. However, the error message is really unhelpful in this regard. lol

Thanks a bunch for your help, Florin! I enjoyed your talk at ElixirConf a couple of years ago and have referenced the video online several times since. :-)

florinpatrascu commented 5 years ago

❤️ ❤️ ❤️