mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 19:08:59 -05:00
[GH-ISSUE #8425] Use OAuth Profile Picture (e.g., Microsoft Entra ID) as User Avatar in OpenWebUI #30649
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jeannotdamoiseaux on GitHub (Jan 9, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/8425
Feature Request
Is your feature request related to a problem? Please describe.
When users log in via OAuth providers (e.g., Microsoft Entra ID), OpenWebUI does not currently fetch and display their profile picture from the OAuth service. This limits personalization and requires users to manually upload a profile picture or stick with the default avatar.
Describe the solution you'd like
OpenWebUI should fetch and use the profile picture from the user's OAuth account after login. For example:
Request the profile picture during the OAuth flow (e.g., using Microsoft Graph's GET /me/photo/$value for Microsoft Entra ID) after obtaining appropriate permissions like User.Read.
Save the profile picture in the user’s OpenWebUI profile and display it in relevant places (navigation bar, comments, etc.).
Describe alternatives you've considered
Additional context
I’m new to the repo but willing to help implement this feature. A pointer on where OAuth and user profile logic resides in the codebase would be greatly appreciated. Thank you!
@rgaricano commented on GitHub (Jan 9, 2025):
1dfb479d36/backend/open_webui/utils/oauth.py (L257)@jeannotdamoiseaux commented on GitHub (Jan 9, 2025):
That’s strange—I’m not sure why it’s not working on my end. Could there be any specific configuration or setup difference that might be causing this issue?
@rgaricano commented on GitHub (Jan 9, 2025):
Sorry, I haven't tried oauth, I'm just trying out other aspects right now.
While someone who is more familiar with it answers you, you can take a look at the documentation on environment variables and check that you have configured the ones that refer to oauth... https://docs.openwebui.com/getting-started/advanced-topics/env-configuration/#enable_oauth_signup
;-)
@robert-mcdermott commented on GitHub (Jan 14, 2025):
@jeannotdamoiseaux, I'm currently using LDAP against a local Active Directory for authentication, but need to move to SAML/OAuth/SSO against our Entra ID tenant. Based on your feature request, it appears that you have already gotten this working. The Open WebUI docs don't explain how I can accomplish this, can you point me in the right direction? Thanks.
@jeannotdamoiseaux commented on GitHub (Jan 14, 2025):
The docs can be found here.
@rragundez commented on GitHub (Jan 14, 2025):
@jeannotdamoiseaux is it working for you?
I have OAUTH configured with MS Entra ID and all working but I cannot get the
pictureclaim. When I look at the user data, printing it in oauth.py (1dfb479d36/backend/open_webui/utils/oauth.py (L258)) print(user_data) I do not see apicturefield or similar with the picture url.I am a bit lost ATM with this.
@jeannotdamoiseaux commented on GitHub (Jan 14, 2025):
For me OAuth is working using MS Entra ID, but the picture claim is not.
@rragundez commented on GitHub (Jan 14, 2025):
ah OK, same here
@robert-mcdermott commented on GitHub (Jan 14, 2025):
@jeannotdamoiseaux, Thanks, I found that, but what method are you using?
@rragundez commented on GitHub (Jan 15, 2025):
@jeannotdamoiseaux take a look, a thumbs up would be nice to raise it to owners of the repo:
https://github.com/open-webui/open-webui/pull/8566/files
@rragundez commented on GitHub (Jan 15, 2025):
@robert-mcdermott this particular thread is about the microsoft oauth (https://docs.openwebui.com/features/sso/#microsoft)
You basically have to create an application in Entra ID and get the values for:
MICROSOFT_CLIENT_ID - Microsoft OAuth client ID
MICROSOFT_CLIENT_SECRET - Microsoft OAuth client secret
MICROSOFT_CLIENT_TENANT_ID - Microsoft tenant ID - use 9188040d-6c67-4c5b-b112-36a304b66dad for personal accounts
Hope that helps!
@jeannotdamoiseaux commented on GitHub (Jan 15, 2025):
Great work!
@jeannotdamoiseaux commented on GitHub (Jan 17, 2025):
@rragundez, it's still not working on my end. I don’t see any errors in the logs, so I’m unsure what might be causing the issue.
@rragundez commented on GitHub (Jan 17, 2025):
Mmm I double checked and with the access token it works. Your application does need the permissions in EntraID, the delegated permission from Microsoft graph user.read and profile picture.
@jeannotdamoiseaux commented on GitHub (Jan 17, 2025):
Is this configuration insufficient to retrieve the profile picture? Here's a screenshot for reference:
@rragundez commented on GitHub (Jan 17, 2025):
I also added the "ProfilePhoto.Read.All" @jeannotdamoiseaux
@jeannotdamoiseaux commented on GitHub (Jan 17, 2025):
I'm currently waiting for admin approval and will report the results later.
@mittalpatel130 commented on GitHub (Jan 17, 2025):
Great work! @jeannotdamoiseaux .. I am still struggling with Microsoft Authentication. I set up all the variables it seems correctly and also the app registration. But, I am not sure what am I missing.
I get this error message -
{
"detail": "The email or password provided is incorrect. Please check for typos and try logging in again."
}
Variables I set -
What should be the values for variables from (6-10)?
If you could please help me?? Thank you in advance!
@rragundez commented on GitHub (Jan 17, 2025):
Hi @mittalpatel130 I will try to help but I think you should read teh documentation carefully because the information is there if you read it with enough patience.
The fact that you are getting "The email or password provided is incorrect" should tell you that some conceptual understanding is missing because the whole idea of using Microsoft to log is, is that you do not have to login to the application itself but via the Microsoft Auth flow. And if the MS Auth flow is giving you that message then indeed it means your password is incorrect.
WEBUI_AUTH=True
if you are giving access via MS Auth then it makes no sense to allow people to register or login via the app
ENABLE_SIGNUP=False
ENABLE_LOGIN_FORM=False
ENABLE_OAUTH_SIGNUP=True
MICROSOFT_CLIENT_ID=
MICROSOFT_CLIENT_SECRET=
MICROSOFT_CLIENT_TENANT_ID=
ENABLE_OAUTH_ROLE_MANAGEMENT=True
@rragundez commented on GitHub (Jan 22, 2025):
@jeannotdamoiseaux can you please provide feedback so we can close this issue?
It has been merged into main and I have deployed on my own use case and I can see the picture.
@mittalpatel130 commented on GitHub (Jan 23, 2025):
@rragundez - Thank you very much for your guidance on Microsoft OAuth setup. It is working now.
Regarding the profile photo - It is not loading and displaying no-photo image with the "alt" text from
tag.
When I inspect this element, I can see it pulled jpeg profile photo in the API response.
Steps I performed:
Is there anything else we have to do? Any CORS settings?
@rragundez commented on GitHub (Jan 23, 2025):
Seems you're missing the headers, but you don't need to change anything it has already been merged and released, just use the last version of open webui
@rragundez commented on GitHub (Jan 25, 2025):
@tjbck I have been running in production for the last week with this change, I think we can close the issue
@jeannotdamoiseaux commented on GitHub (Jan 29, 2025):
I can confirm that this functionality is now working as expected. However, I’ve noticed one issue: accounts created prior to the introduction of this functionality still display the 'anonymous' picture. That said, I’ll be closing this issue since the primary functionality is working.
@koorlan commented on GitHub (Feb 5, 2025):
To keep you informed, after utilizing this service, it works remarkably well. However, if a user does not have a profile picture, it creates an issue because the graph response is encoded in base64, which can be inappropriate. The graph response is as follows:
The resulting image is as follows:
It would be desirable, when the user is not found, to revert to the original avatar:
An even better solution would be to emulate Microsoft Teams and replace the image with an avatar displaying the user's initials.
@jeannotdamoiseaux commented on GitHub (Feb 5, 2025):
Also see #9327 for this
@koorlan commented on GitHub (Feb 5, 2025):
oh perfect we are aligned :D
@chaiyr commented on GitHub (Feb 10, 2025):
I have the same issue, the MS Oauth work nicely but the picture not show up. I found out that I have to add scope "https://graph.microsoft.com/User.Read" to MICROSOFT_OAUTH_SCOPE env.
@mateuszdrab commented on GitHub (Feb 10, 2025):
@chaiyr
I'm also trying to get this to work with Entra ID, does the username properly propagate into Open WebUI for you?
Aside from the broken picture, I'm seeing the username is the email address and the email address is empty in the edit dialog but shows fine on the user list.
@chaiyr commented on GitHub (Feb 11, 2025):
@mateuszdrab yes, now I get it works both Username and profile image. As of V0.5.10, I edit the Oauth.py
line 284 from
if not isinstance(user, str): === > if not isinstance(name, str):
@koorlan commented on GitHub (Feb 11, 2025):
for the name's issue its already merged onto dev , ship with the next release
https://github.com/open-webui/open-webui/pull/8493
@mateuszdrab commented on GitHub (Feb 11, 2025):
Awesome, understood. Will wait the next release.
Thanks for confirming