https://supabase.com/ logo
#off-topic
Title
# off-topic
r

ricky

04/07/2022, 11:03 PM
is it possible to signin using multiple oauth providers?
g

garyaustin

04/08/2022, 12:35 AM
Unless there is more recent info I missed this discussion sort of covers it. https://github.com/supabase/supabase/discussions/5827 Basically yes with same email, with limit on email/password login and one SB dev saying yes, but nothing documented. 😎
r

ricky

04/08/2022, 12:36 AM
I was talking about multiple oauth providers like github, gmail, discord etc..
i dont want to link an email to a provider
g

garyaustin

04/08/2022, 12:37 AM
Yes that is the topic
They all use email in Supabase auth table as identifier.
r

ricky

04/08/2022, 12:39 AM
ok is this how you would use multiple providers?
Copy code
javascript
    const signin = async () => {
        const { user, session, error } = await supabase.auth.signIn({
            provider: [
                'discord',
                'github'
            ]
        })
    }
so you're saying if the email is the same for both the user's discord and github profiles then they will automatically be linked to the same profile?
g

garyaustin

04/08/2022, 12:41 AM
Yes
r

ricky

04/08/2022, 12:42 AM
ok is my code correct?
g

garyaustin

04/08/2022, 12:47 AM
My yes was to they are linked by email. I don’t think your code will work. I don’t use 3rd party providers, myself. But that does not seem like it could work as user needs to decide which one to use before you make the signIn call, as the next step after that is the call to the provider API in auth.
r

ricky

04/08/2022, 4:40 AM
I tried signing in with multiple providers but I keep getting this error message
Copy code
time="2022-04-08T04:09:01Z" level=error msg="500: Database error saving new user" component=api error="failed to close prepared statement: ERROR: current transaction is aborted, commands ignored until end of transaction block (SQLSTATE 25P02): ERROR: duplicate key value violates unique constraint \"users_email_key\" (SQLSTATE 23505)" method=GET path=/callback referer= remote_addr="172.22.0.2:58988" request_id=88385e67-162d-40d7-b4f6-bd990da35a12
note ERROR: duplicate key value violates unique constraint \"users_email_key\"
because it
auth.users
table includes a email column that must be unique so it seems like when I try to login with my github account it tries to add my account but my discord account already exists in the table with the same email
any advices?
i think this whole linking accounts stuff only works if your trying to link an existing email account to a 3rd party provider
i dont think it works if you're try to link accounts between two 3rd party providers
please someone correct me if I'm wrong. thanks
g

garyaustin

04/08/2022, 8:31 PM
@ricky I just created a Github auth app (I already had a Discord one from previous testing. I have a test user with email in SB. I signed in with provider:'github', user, new identity was added and logged in. I changed code to signup with discord. A 3rd identity was added to same user and I was logged in. I then went back to Github signin and was able to signin. Pictures show identity table and session/user object in client with all identities using same email. I then deleted the user. Signed in with Discord and then signed in with Github. No errors both signed in to app and there are two identities in table and in user object as provider array with github and discord. I did the second test to make sure having a first email account did not impact things.
I also looked thru the gotrue server code and there is alot of code dealing with providers and identities tables that would have no use if just a single one at a time was allowed.