GitHub authentication doesn't work
I've originally asked about this in #authentication-archive but then it was archived so I'm moving the discussion here (as it still unresolved).
---------------------
Hey guys, I'm trying to setup github authentication. I followed the guide but it doesn't work π¦ when I click " Sign in with Github " it opens
I guess I should change something in my router?
http://localhost:4000/auth/user/github
but doesn't redirect.
I guess I should change something in my router?
GITHUB_REDIRECT_URI
is set to http://localhost:4000/auth



27 Replies
Routes
/auth/user/github
responds with 401
@jart:
The 401 means that itβs not finding the route and just dropping through to the failure route. Can you show your auth dsl config?
π€ can you go to your
AuthController
and see if its getting to the handle_failure
? There could be something totally unrelated that is broken here
but the handle_failure
might be swallowing any errors running the actionsSo what does
reason
look like in that failure hook?π there it is
you're supposed to return
{:ok, value}
from secrets
We should raise an error
if it doesn't match. But yeah thats the problem.ooo
You can use
fetch_env/2
for thatcool, thanks!
now it redirects to GitHub but then it seems to conflict with password strategy or something like that
I think you just need to make that attribute allow nil
should I
allow_nil?: true
for hashed_password
?Yeah, if you want to support social sign ins
okay, now this error:
** (ArgumentError) No identity found for OpenStatus.Accounts.User called :email
i guess I need to take some data from the user_info
?Yep, you can see how we do it in
ash_hq
And you probably are missing an identity for email
identity :unique_email, [:email]
hmm i have this already:
copied this from the guide
Yeah, we should probably update it with my code snippet above
Because the default set up the user will get a "confirm your email" email when signing up with github
But if you combine my example with
in the confirmation sender, you can avoid that
I don't have email confitmations
As for your error message, I think its just telling you that you're referring to an identity called
:email
somewhere that doesn't existi think it called
:unique_email
in my projectHmm...I guess it could be something in ash_authentication that is assuming your identity name but that doesn't sound likely
I'd hunt around for somewhere you're using the
:email
atom where you should be using :unique_email
yeah I found that, all is good and working now!
thanks a lot!
another minor issue: it seems that CSS is a bit off:

I've added
"../deps/ash_authentication_phoenix/**/*.ex"
to assets/tailwind.config.js
Yeah, so I think its reacting to your dark mode already
but the overarching template doesn't set the background color
I have this in an example app I'm working on
In the root
Because I hadn't set up the rest of my app for dark mode, so I only wanted to set the bg to black on the sign_in pages
this helped, thanks!
glad to help! Mind marking this as resolved and closing it? Feel free to open as many more as you want.
done