auth icon indicating copy to clipboard operation
auth copied to clipboard

Error getting user email from external provider only with public Azure /consumers/ tenant

Open automaton82 opened this issue 10 months ago • 2 comments

Bug report

  • [x] I confirm this is a bug with Supabase, not with my own application.
  • [x] I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

When using oauth with Azure and the personal accounts only tenant, the oauth call does not work and the error Error getting user email from external provider happens everytime.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Setup an oauth call with MSFT. When you set it up, ensure your app registration is Personal accounts only
  2. As per supabase documentation and microsoft's, use https://login.microsoftonline.com/consumers/ as the tenant URL
  3. Ensure email is added in the scope as per the docs, like:
async function signInWithAzure() {
  const { data, error } = await supabase.auth.signInWithOAuth({
    provider: 'azure',
    options: {
      scopes: 'email',
    },
  })
}

Expected behavior

This should work

System information

  • OS: Windows and hosted
  • Browser all
  • Version of supabase-js: 2.39.3
  • Version of Node.js: 20.12.2

Additional context

This appears similar to https://github.com/supabase/auth/issues/550 but in that issue people said personal accounts worked fine, it was /common/ that did not. Now it seems the opposite

automaton82 avatar Apr 21 '24 01:04 automaton82

Supabase Auth requires that the user have an email address present. Are you sure the user account has one?

hf avatar Jun 06 '24 13:06 hf

Yes I am sure (it's me signing up to test it).

automaton82 avatar Jun 06 '24 13:06 automaton82

hi @automaton82, if you're still running into this error, please open a ticket at https://supabase.help - it helps us investigate the issue alot more easily since we'll be able to investigate your project's logs.

kangmingtay avatar Aug 29 '24 18:08 kangmingtay

same issue

zhyjiong avatar Sep 21 '24 14:09 zhyjiong

i fixed the issue by adding 'scope': 'email' in options, just like official example:

async function signInWithAzure() { const { data, error } = await supabase.auth.signInWithOAuth({ provider: 'azure', options: { scopes: 'email', }, }) }

zhyjiong avatar Sep 21 '24 14:09 zhyjiong