niamtokik
Hey guys!
Firstly, I am happy to finally have an account on elixir forum and share my experience with all of you! It’s a real pleasure to be there!
I am currently working on a pretty big project based on Erlang/Elixir (API in Elixir and backend in Erlang). Actually, I am more an Erlang developer than Elixir one, and I have some issue with Ueberauth. I was looking around and did not find any blog post or big example about integrating it with Phoenix (1.4+).
If you don’t have any example or links… Can you give me some feedback about this framework, or other alternative (I tried guardian a little, but don’t have any experience with it).
Many thanks in advance!
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 7- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
OvermindDL1
The integration is identical to older Phoenix’s so the existing docs should work fine. I’ve been using ueberauth with phoenix since 1.1 days and I’m on 1.4 still without issue.
If you are getting errors or anything, please post them here and we can help!
On a side note, if you don’t know or care what JWT is or don’t need to transfer information securely between non-communicating servers via the client, then you don’t need to touch Guardian at all.
niamtokik
Thanks for the reply! Actually, I don’t have any kind of issue, I was just thinking about how things really work and how to make something “clean” by looking some real life example. I was thinking to make my own interface first based on oauth1 and oauth2, because I need to manage some user token, and don’t know how to get those information easily with ueberauth.
sanswork
Have you checked out GitHub - ueberauth/ueberauth_example: Example Phoenix application using Überauth for authentication · GitHub
alvises
Hi @niamtokik, welcome to the forum!!
I’ve just started to use this library this week and I had the same feeling - before having a decent understanding of what to do, I had to do quite a bit of research
I didn’t have clear which steps I had to follow and in which order, especially merging the steps of the library with the customization of the Strategy.
I needed it just to make the user login via a GitHub Oauth app, but as you maybe have seen it’s possible to configure the library with a ton of different services (called Strategies): List of Strategies
So, this is what I did and resources I’ve used.
I’ve found useful the GitHub strategy documentation: Ueberauth.Strategy.Github
1) In my case (GitHub) what I’ve done is to configure
Ueberauthinconfig/config.exslike thisIn this way I request only personal info
default_scope: "user", like name, email and avatar picture. Each strategy has its owndefault_scopestring.2) After creating the Github app, I’ve configured the strategy with client id and secret, always in the configuration file
3) Then I created the Phoenix controller that handles the request and callback, like this example
plug Ueberauthadds the request phase to the Auth controller, and when theMyApp.AuthController:requestaction is called, it redirects the user to the GitHub authorization page.4) To use this controller I’ve then added these routes in
router.ex(like the example in the Ueberauth github repo)I kept the same default values. In this way, if you make a GET HTTP request with your browser to
/auth/github, the:requestaction is called with"github"provider param, and it redirects you to the GitHub auth page.Then, when you authorize the GitHub page, you are redirected to
/auth/github/callbackwhich triggerscallback_phase(%{ assigns: %{ ueberauth_auth: auth } } = conn, params)and you can useauthto get all the data you need.The example that @sanswork has shared it’s super clear, but let me know if something isn’t clear.. I’d be happy to share part of the code I’ve done so I can be more specific.
cnck1387
There’s a real world updated implementation of it at GitHub - thechangelog/changelog.com: Changelog makes world-class developer pods. This is our open source platform. · GitHub. You can see a demo of it at Sign In.
niamtokik
Thanks for all these great answers! I was looking on my side too, and find some great post:
Thanks @alvises for your really useful answer! On my side, I tried to debug some existing ueberauth modules, like linkedin one (Permission issue during authentication by niamtokik · Pull Request #10 · fajarmf/ueberauth_linkedin · GitHub).
Thanks @cnck1387, I will take a look. The project seems really interesting! Are you working on this project? Because I am interested about the design of the database, in particular the way I can store token and reuse them? I mean, I read the
router.ex(changelog.com/lib/changelog_web/router.ex at master · thechangelog/changelog.com · GitHub) file and take a look around the code, but, it seems token from github or twitter are not stored. I guess the session is stored in the cookie, but there is no data stored somewhere for that (except, obviously, for the information about the user like email or password).@sanswork I already hacked around this code (my first PoC was based on), but there is a lack of real world example with comments and documentation, a kind of “how to use ueberauth, and write new strategies”.
Anyway! Thanks for your answers!
cnck1387
I do work on the project, but I’m not a core developer. I am just a random person who stumbled onto the project while learning Phoenix and have sent in a few small pull requests.
I mainly use their code base as a reference guide for my project, although I don’t use the ueberauth feature in my app. Their site supports both signing in with an account you can create with an email address OR you can use a social login instead.
Just glancing at the code in the auth controller, it looks like if you try to sign in with Twitter or something, then ueberauth will determine if the person successfully authenticated and then it pattern matches on the
callbackto see what to do next.If it’s bad, the login never happens. If it’s good, it attempts to look up the user by the Twitter handle they used to authenticate. If that was a success, it logs them in. Otherwise it sends them to a
/joinpage to create an initial account with as many fields pre-filled in as possible from the ueberauth data.The token doesn’t get stored from github or twitter, but info about the user is stored. In either case (logging in with a custom account you created or twitter) the
sign_in_and_redirectfunction gets called in the auth controller which sets up the session and saves the cookie.