auth: Azure Auth: http://localhost:5000/?error=server_error&error_description=Error+getting+user+email+from+external+provider

Bug report

When I login using Azure Auth for a newly created Azure App Registration, I get this error

To Reproduce

  1. Register a new app registration in azure portal, giving access to organisations and personal accounts
  2. Register the supabase redirect uri as a “Web” redirect uri (in azure portal)
  3. Create a secret for this new app registration
  4. enable azure auth in supabase, pasting in the client id and secret of the new app registration
  5. Invoke:
const {user, session, error} = await supabase.auth.signIn({
            provider: 'azure',
        })
  1. That calls https://rlgaaitetwbkhisssmkq.supabase.co/auth/v1/authorize?provider=azure
  2. Which returns with a 302 to https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=16d4a427-b73c-45fc-b04f-9545e7273f21&redirect_uri=https://rlgaaitetwbkhisssmkq.supabase.co/auth/v1/callback&response_type=code&scope=openid&state=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJle…
  3. Which returns with a 200 and pops the Microsoft Auth dialog, asking for me to grant permission to the app. Note, it does not ask me what Microsoft identity to use, I assume its using the identity I am using to log into Azure Portal.
  4. I grant permission, then it seems to load https://login.live.com/Me.htm?v=3
  5. Then it seems to load https://login.live.com/oauth20_authorize.srf?client_id=16d4a427-b73c-45fc-b04f-9545e7273f21&scope=openid&redirect_uri=https://rlgaaitetwbkhisssmkq.supabase.co/auth/v1/callback&response_type=code&state=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ....&uaid=95c5d4c9a43f406ca88c5b1b22ea432a&msproxy=1&issuer=mso&tenant=common&ui_locales=en-GB
  6. Then it loads https://account.live.com/Consent/Update?mkt=EN-GB&uiflavor=web&id=293577&ru=https://login.live.com/oauth20_authorize.srf?uaid=95c5d4c9a43f406ca88c5b1b22ea432a&opid=A353DB724539E16F&opidt=1640691597
  7. Eventually we get to https://login.live.com/oauth20_authorize.srf?uaid=95c5d4c9a43f406ca88c5b1b22ea432a&opid=A353DB724539E16F&opidt=1640691597&res=success&route=R3_BAY
  8. which returns a 302 to https://rlgaaitetwbkhisssmkq.supabase.co/auth/v1/callback?code=M.R3_BAY.f96be895-105c-c9f1-5462-d0b31af76746&state=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ey…
  9. Invoking https://rlgaaitetwbkhisssmkq.supabase.co/auth/v1/callback?code=M.R3_BAY.f96be895-105c-c9f1-5462-d0b31af76746&state=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ey… returns a 302 to http://localhost:5000/?error=server_error&error_description=Error+getting+user+email+from+external+provider

Expected behavior

I have done the same steps for Google Auth, and it worked, expect the same to happen for Azure auth.

Also, I have successfully logged in using Azure using similar steps using the Microsoft Native javascript sdk for auth, @azure/msal-browser

I am aware of https://github.com/supabase/gotrue/pull/54 , but two things on that. The first is: I was not presented with an option to select an email address to login with (presumably because I am already logged into azure portal?) but even if I was, the second point is that I don’t expect my customers to login using this weird azure specific email address. I expect them to login using their “usual” azure identity.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 6
  • Comments: 41 (11 by maintainers)

Most upvoted comments

Reopened, thanks for commenting on this. Looking into it!

As an update, the Auth team are aware and looking into the issue currently; it was not an easy one to reproduce but it is being actively worked on!

HI @dabbijak Thanks for the steps, the email scope is already documented in our main docs here. The issue is with AD not returning the email address in the response (unless it has been manually set by the Org owner or the user themselves) as they are not mapped.

As this is an AD issue, primarily, I would opt to close this until Microsoft is able to respond with a fix. If people disagree with the decision and want to keep it open, please react with 👎 (to save commenting noise) and we can reopen!

Hey everyone, GoTrue requires that Azure provide back an email address for the user that is signing in. Make sure you always use this code snippet which includes the email scope:

async function signInWithAzure() {
  const { user, session, error } = await supabase.auth.signIn(
    {
      provider: 'azure',
    },
    {
      scopes: 'email',
    }
  )
}

Please reopen the issue if this does not solve the problem for you.

Without any modifications on our end, sign in with Azure is breaking with ?error=server_error&error_code=500&error_description=Error+getting+user+email+from+external+provider - tried everyhing I could think of and all suggestions across this and similar issues, nothing is working so far.

@dzoba Just to make sure this issue is only impacting the same setups, can you confirm:

  1. You are not using a personal Azure account
  2. You do not have a custom tenant
  3. Your Entra URL is https://login.microsoftonline.com/common

Thanks!

@encima the answers here are the same as in our email exchange - same product 😄

Thanks @encima ! This kills Azure signups for us and makes us look quite bad in front of our customers who previously were able to use Azure auth to sign in but now are forced to send magic links as a fall back until this is fixed.

I’m also having this issue and fixe above did not resolve it.

@zomchak-code I’m experiencing the same

@hf You mentioned this issue should be reopened if scopes: 'email' doesn’t solve the problem.

The problem still exists, and can be reproduced. I can see a lot of people experiencing this. Let me know if you can reproduce this and if this issues should be reopened or a new created.

I’m pretty sure I’ve checked everything on the setup side and the access is really in granted, but this error still persists

To reproduce

Screenshot 2024-01-30 at 18 29 11 Screenshot 2024-01-30 at 18 29 18

I have the same issue

Hey so there was a report that on some Azure accounts the email is encoded differently. @silentworks do you recall?

I can confirm that if I log out of Azure portal, I am prompted to enter an email address