https://supabase.com/ logo
#help
Title
# help
a

arzy

04/15/2022, 10:31 PM
Hey! Trying to get the Discord Auth to work and ive used
Copy code
const signInWithDiscord = async () => {
    const { user, session, error } = await supabase.auth.signIn({
      provider: 'discord',
    })
    console.log(user,session,error)
  }
this to fire on button click but the page switches to the login page and loses track of user, session and error
n

Needle

04/15/2022, 10:31 PM
Hello @arzy! This thread has been automatically created from your message in #843999948717555735 a ``few seconds ago``. Pinging @User so that they see this as well! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ... menu) and select Leave Thread to unsubscribe from future updates. Want to change the title? Use the
/title
command! We have solved your problem? Click the button below to archive it.
g

garyaustin

04/15/2022, 10:35 PM
When using 3rd party auth, signIn does not comeback basically with anything. You need a redirectTo if you want to control where it goes, otherwise it uses your default in auth settings for the destination page.
n

Needle

04/15/2022, 10:35 PM
arzy (2022-04-15)
a

arzy

04/15/2022, 10:39 PM
Ah okay I see - so im trying to get the users discord username to be displayed, how would I be able to get access to that if signIn does not return with anything?
g

garyaustin

04/15/2022, 10:45 PM
If you put
Copy code
supabase.auth.onAuthStateChange((event, session) => {
  console.log(event, session)
})
on your return page, you should see a signin event with session which will have a user object in it, or you can use .auth.user() ... after the signin event occurs
a

arzy

04/15/2022, 11:14 PM
Yo you just saved me
Thank you
I couldnt find this anywhere on the docs
Bless you