Use Uberauth in a Plug only application

Hey :wave:

I’m trying to build a really simple and minimalist web app without Phoenix and I would like to use Uberauth since it’s plug based and supports a lot of strategies out of the box.

Unfortunately, I can’t find any examples on how to use it on a plug only application since all examples are focused on Phoenix.

Anyone can give me some hints on how I could move forward? My current idea is to try and replicate whatever plugs are used in a :controller from Phoenix but that strategy it’s a bit naive :sweat_smile:

Thank you in advance :pray:

2 Likes

Howdy @filipecabaco :wave: I responded to you on Twitter (a far better place to reach me, at least) but thought I’d follow-up here just in case.

Ueberauth will indeed work with Plug but I don’t immediately have an example for you. Making it work with Plug should be fairly straight forward. What have you tried so far? Is this code available on GitHub to be reviewed?

I don’t have the bandwidth these days to put together sample projects for everything but if you’d like to contribute an example to the Ueberauth org that would be amazing :grin:

1 Like

Will post here what I posted on Twitter:

Thank you in advance

Wrote a small app to follow as an example https://github.com/filipecabaco/plug_example
My first idea was to look up what plugs a controller from phoenix uses and basically copy-paste them ( https://github.com/phoenixframework/phoenix/blob/v1.5.3/lib/phoenix/controller.ex#L1 )

But this feels naive and over-complicated

I don’t fully understand the flow of plugs and that is the main pitfall at the moment … I would love to have the small example project with a callback endpoint receiving :provider and redirect to root (similar to uberauth docs).

And of course! I would love to share and at the moment it’s an example that is non-existent which would benefit the community.

1 Like

@filipecabaco I have opened a PR on your project that gets the GitHub strategy working (it is very basic): https://github.com/filipecabaco/plug_example/pull/1

I left a few comments to explain things. Let me know if this helps.

2 Likes

Wow, this is awesome! Thank you so very much!

Will sanitize it and prepare to push something into uberauth docs.

1 Like

Thank you so much, this would be wonderful :tada:

1 Like