-
|
Hi, I've been miserably failing while trying to setup ms oauth. I hope someone points my error. So I did the following:
I use the below selection to do SPA and trying by giving it all the auth methods. I use the callback url from librebooking; https://my.librebookin.com/Web/microsoft-auth.php
I get the ClientID from here.
I get the secret ID from here.
This gives me the MS login button at LB login. I get through the MS login path, and it throws me back to LB with firefox console having this error message from MS:
What do I do wrong here? My app is hosted in kubernetes from librebooking container via http. It has cloudflared in front publishing the application as http/https in public domain name. This is just a test setup while I figure out if LB is good for me or not. If we decide using it, it goes directly to some internet hosting with no cloudflared. But I don't think this should make a difference. For reference, the google auth worked immediately. |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments
-
|
Here is what various AI tools said. I would like to be able to answer this myself but I have zero experience with this. I have only used LDAP. So takes these answers with a lot of skepticism Gemini's responseIssue SummaryThe user is attempting to set up Microsoft OAuth for a LibreBooking instance hosted on Kubernetes (behind a Cloudflare tunnel). They have successfully configured Google Auth, but Microsoft Auth is failing.
The Root CauseThe error occurs because the user chose the SPA platform in Azure EntraID.
Recommended FixThe user needs to change the platform type in the Azure Portal:
ChatGPT's responseRoot causeYou registered the Azure/Entra application as an SPA (Single-Page Application), but LibreBooking performs a server-side OAuth authorization code exchange using the PHP endpoint Microsoft treats SPA redirects as public clients and requires PKCE. LibreBooking’s current PHP flow likely does not send PKCE, so Microsoft returns: "Proof Key for Code Exchange is required for cross-origin authorization code redemption" This is a configuration mismatch, not a bug in LibreBooking. Recommended Fix (most common solution)Change the app from SPA → WebIn Microsoft Entra: App registrations → Your app → Authentication
Why this worksType: SPA Type: Web LibreBooking is a PHP server app, so it must be registered as Web. Very common second mistakeUse Client Secret VALUE, not Secret ID. In Entra → Certificates & Secrets → Client secrets:
If you paste the Secret ID, token exchange fails. Sanity checklistBefore testing again: [ ] Platform is Web When would you actually need PKCE?Only if you intentionally want:
Then LibreBooking would need code changes to add:
For a PHP backend, this is unnecessary. TL;DRSwitch SPA → Web and use the secret VALUE. That should immediately resolve the error. Claude's responseThe issue is that you've registered the app as a SPA (Single Page Application) in Azure, but LibreBooking is a server-side PHP application that needs a Web app registration instead. Solution: Change Azure App Registration Type1. Go back to your app registration in Azure Portal
2. Remove the SPA platform configuration
3. Add a Web platform instead
4. Verify your Client Secret is still valid
Why this fixes it
Alternative ChecksIf you want to keep troubleshooting, you could also check:
Note: Since Google OAuth worked immediately for you, this strongly suggests the app registration type is the issue - Google's setup probably defaulted to the right configuration. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the tips. I went back to SPA -> Web. This also goes through the MS auth process, but now fails at LB end: I checked, the client ID, tenant ID and secret ID are the same as in azure portal. |
Beta Was this translation helpful? Give feedback.
-
|
And now by setting secret value instaed of secret id, I get further with auth. Like if it went through, but email not found: |
Beta Was this translation helpful? Give feedback.
-
|
Here are some responses. GeminiThe 1. Secret Value vs. Secret ID (Most Common)In the Azure Portal, under Certificates & secrets, you will see two columns: Value and Secret ID.
Note: The Value is only visible immediately after you create the secret. If you didn't copy it then, it will be masked (e.g., 2. Kubernetes Secret EscapingSince you mentioned your app is hosted in Kubernetes, how are you passing the secret?
3. URL Encoding / Special CharactersAzure secrets often contain characters like
4. "Web" Redirect URI MismatchSince you switched from SPA to Web, ensure that the Redirect URI is explicitly listed under the Web platform section in Azure.
Next Step to Debug: curl -X POST [https://login.microsoftonline.com/](https://login.microsoftonline.com/)[TENANT_ID]/oauth2/v2.0/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "client_id=[CLIENT_ID]" \
-d "scope=openid profile email" \
-d "code=[AUTHORIZATION_CODE_FROM_URL]" \
-d "redirect_uri=[https://my.librebookin.com/Web/microsoft-auth.php](https://my.librebookin.com/Web/microsoft-auth.php)" \
-d "grant_type=authorization_code" \
-d "client_secret=[SECRET_VALUE]"If this returns the same 401, the issue is definitely the client_secret string itself. ChatGPTThat The key pointIn Entra → Certificates & secrets → Client secrets, each secret has two identifiers:
LibreBooking needs the Value. If you paste the Secret ID, you’ll get exactly the 401 invalid_client you’re seeing. What to do1) Create a new client secret and copy the ValueBecause Microsoft only shows the secret value once:
2) Confirm you’re editing the correct app registrationIt’s easy to copy a client ID from one app and a secret from another. Make sure:
3) Watch for “secret got mangled” issuesA surprising number of failures come from copy/paste problems:
If you’re storing it in a Kubernetes Secret, double-check you didn’t accidentally base64 the wrong field, or include quotes in the literal. 4) If you’re using a certificate-based credential (rare)If you configured the app to use a certificate rather than a client secret, then you can’t use client_secret at all. But your error indicates LibreBooking is sending client_secret, so you should have a valid secret value. Quick “this is the mistake” litmus testYou wrote: “client ID, tenant ID and secret ID are the same as in azure portal.” That strongly suggests you are indeed using the Secret ID field. The fix is: use the Secret VALUE (and usually generate a new one so you can copy it cleanly). If you paste (redacting the secret) the snippet of LibreBooking config where you set Microsoft OAuth, I can point out exactly where the secret should go and what formatting to avoid (especially if it’s coming from env vars / Helm). ClaudeAh! The issue is likely that you're using the Secret ID instead of the Secret Value. This is a very common mistake! The ProblemWhen you create a client secret in Azure, you get two different values:
You need to use the Secret Value, not the Secret ID. How to Fix ItOption 1: If you still have the secret value visibleWhen you first created the secret, Azure showed you the Value column. You need to copy that value (it's usually a long random string). Option 2: If you didn't save the secret valueIf you didn't copy the secret value when you created it, you'll need to:
Additional Checks
|
Beta Was this translation helpful? Give feedback.
-
|
it fails getting email: [2026-02-08T19:59:46.700613+00:00] sql.ERROR: [User= ()] MySql Query: SELECT * FROM It gets name from MS, but not email [2026-02-08T19:59:46.724144+00:00] sql.ERROR: [User= ()] MySql Execute: INSERT INTO Sounds like it fails to get email, and tries to create a new user without email. Two problems here, why does it fail getting email, and second, LB has a bug trying to create user with no email. |
Beta Was this translation helpful? Give feedback.
-
GeminiNice! Getting the name means the handshake is working—now we just have to fix the "identity crisis" where Azure is being stingy with the email address. The SQL error shows that Here are the three things you need to check in the Azure Portal: 1. Check API Permissions (Scopes)LibreBooking needs the right scopes to ask Microsoft for the email.
2. Check Optional Claims (The "Email" toggle)By default, Azure doesn't always include the email in the token even if you have the permission.
3. Ensure the User actually has an Email fieldIn EntraID, check the user profile you are testing with.
Why the SQL FailedLooking at your log: LibreBooking is trying to find an existing user to "match" the login, but since Microsoft sent Next step: Try adding the Optional Claim for email first. That is the most common reason the "Name" arrives but the "Email" stays empty. ChatGPTYou’re past OAuth now — the remaining problem is simply that LibreBooking is not receiving an “email” value from Microsoft, so it ends up querying/inserting with
That means the Microsoft user profile response LibreBooking is parsing contains a name but not an email-like field (or LB is looking at the wrong field). Why email is often missing with Entra IDFor Entra ID users, an email can be absent for several valid reasons:
What to check in Entra (fastest path)1) Verify the user actually has an email-like attributeIn Entra Admin Center:
If 2) Confirm delegated Graph permissions + consentApp registrations → your app → API permissions:
If LB’s Graph call lacks permission, you’d usually see a Graph 401/403 in logs — but it’s still worth confirming. 3) Add/emit the right claim (optional claims)If LibreBooking is relying on ID token claims instead of Graph:
Even with optional claims, if the directory doesn’t have an email, What to change in LibreBooking (practical fix)LibreBooking should not assume
So the mapping should be roughly: email = mail ?? userPrincipalName ?? preferred_username And it should refuse login (with a clear error) if all are empty, rather than inserting a user with null email. The SQL you pasted also reveals a separate bugThis query is wrong SQL logic:
So LB is probably building a query with a bound parameter that is NULL and then comparing with That doesn’t cause the “missing email” — but it does mean LB won’t find an existing user if the identifier is null, and then it inserts a broken user record. Suggested next steps
If you paste the section of LibreBooking that parses the Microsoft user info (or point me to the exact file/function in the repo you’re running), I can suggest the precise patch (a few lines) to implement the fallback cleanly. ClaudeGreat progress! Now the issue is that LibreBooking isn't receiving the email address from Microsoft. This is because you need to grant the correct API permissions in Azure. The ProblemMicrosoft OAuth isn't returning the email address because the app doesn't have permission to read it. The logs show:
Solution: Add API Permissions in Azure1. Go to your app registration in Azure Portal2. Navigate to "API permissions"
3. Add the required Microsoft Graph permissions
4. Grant admin consent (if required)
5. Verify the permissionsYour API permissions should look like:
Alternative: Check the Scope ParameterIf the permissions are already added, LibreBooking might not be requesting them in the OAuth flow. The application should request these scopes: You may need to check LibreBooking's Microsoft OAuth configuration to ensure it's requesting these scopes. After Making Changes
The email should now be passed to LibreBooking and the user creation should succeed. |
Beta Was this translation helpful? Give feedback.
-
|
OK, some success. So turns out I got it working for the account I use azure with by doing the above instructed:
Now it started to work for that account. I dunno if 1 and 2 steps were necessary. Then I tried with another account of mine. It stopped due user not in tenant. Then I changed ms.tenant to common in LB. I tried my work account email, creating the user first into LB. This again has the same problem of not getting email. I assume I can't tell all the MS users to go and check their settings in azure, and users likely could not change the api&token perms anyhow. And it would be too complicated. So I assume this feature is useless outside of some corporate use where org admin can do the above settings. |
Beta Was this translation helpful? Give feedback.






OK, some success. So turns out I got it working for the account I use azure with by doing the above instructed:
Now it started to work for that account. I dunno if 1 and 2 steps were necessary.
Then I tried with another account of mine. It stopped due user not in tenant.
Then I changed ms.tenant to common in LB. I tried my work account email, creating the user first into LB. This again has the same problem of not getting email. I assume I c…