Ueberauth Identity Strategy for a pure json API - How to implement the request phase?

Hi @f34nk,

I actually followed the second article you linked there before I came here:) Unfortunately it doesn’t explain how to set up the simple identity authorization.

Luckily I figured out my problem yesterday: You have to tell Überauth where to look for the credentials in your request.
Just in case anybody should ever stumble over a similar problem, here is how I solved mine:

In your confix.exs you have to do something like

config :ueberauth, Ueberauth,
  base_path: "/api/v1/auth",
  providers: [
    ...
    identity:
    {
        Ueberauth.Strategy.Identity,
        [
          ...
          param_nesting: "user",
          ...
        ]
     }
  ]

The param_nesting: "user" parameter tells Überauth to search the required information (email and password in my case) in the user parameter of your request.

That way you can post a request with a body like this

{
	"user": {
					"email":"john@doe.de",
					"password":"johndoe1234"
	}
}

directly to the ‘callback’ function, without having to provide an extra view and Überauth will recognize it properly.

3 Likes