ueberauth / ueberauth_slack

Slack OAuth2 Strategy for Überauth
MIT License
23 stars 33 forks source link

Support for JSON based API's Unknown #22

Closed alvincrespo closed 6 years ago

alvincrespo commented 6 years ago

Not sure if this is the right place to pose this questions, but I'm a bit confused on the flow of this.

I'm currently trying to implement this library with Guardian 1.0 but running into some issues that I'm not 100% sure of and hoping to get some help.

Question 1 In the documentation it states you can start the request via a GET to /auth/slack. But I'm not sure how that fits with a JSON based API flow?

Question 2 I have a frontend app, built in React that has the "Sign In with Slack" button and that takes the user to Slacks auth page. I then set the redirect to hit /auth/slack as a GET and get the following:

[debug] Processing with IDIWeb.AuthController.callback/2
  Parameters: %{"code" => "XXXX", "provider" => "slack"}
  Pipelines: [:api]
[info] Sent 500 in 369ms
[error] #PID<0.923.0> running IDIWeb.Endpoint terminated
Server: localhost:4000 (http)
Request: GET /auth/slack/callback?code=XXXX
** (exit) an exception was raised:
    ** (ArgumentError) flash not fetched, call fetch_flash/2
        (phoenix) lib/phoenix/controller.ex:1228: Phoenix.Controller.get_flash/1
        (phoenix) lib/phoenix/controller.ex:1210: Phoenix.Controller.put_flash/3
        (ididit) lib/ididit_web/controllers/auth_controller.ex:14: IDIWeb.AuthController.callback/2
        (ididit) lib/ididit_web/controllers/auth_controller.ex:1: IDIWeb.AuthController.action/2
        (ididit) lib/ididit_web/controllers/auth_controller.ex:1: IDIWeb.AuthController.phoenix_controller_pipeline/2
        (ididit) lib/ididit_web/endpoint.ex:1: IDIWeb.Endpoint.instrument/4
        (phoenix) lib/phoenix/router.ex:278: Phoenix.Router.__call__/1
        (ididit) lib/ididit_web/endpoint.ex:1: IDIWeb.Endpoint.plug_builder_call/2
        (ididit) lib/plug/debugger.ex:99: IDIWeb.Endpoint."call (overridable 3)"/2
        (ididit) lib/ididit_web/endpoint.ex:1: IDIWeb.Endpoint.call/2
        (plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4
        (cowboy) /Users/alvincrespo/workspace/personal/ididit/ididit-backend/deps/cowboy/src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4

Basically I'm expecting to return some JSON from this endpoint and my SPA (single page app) will do the redirect. Is this something I can do with the lib as is? Or would I need to fork and adjust to fit my use case?

alvincrespo commented 6 years ago

This was actually an issue on my end. I was using put_flash in my auth_controller by mistake.