Access AzureAD Profile Picture from MS Graph

IT Tech Consulting 1 Reputation point
2020-06-03T15:35:47.54+00:00

I am an AzureAD Developer having a hard time with something I expected to be simple. I can not access any users profile picture, even my own from ms graph.

I have set Directory and User Read Scopes. Profile Pictures Do not appear in the AAD User Manager. My code C# can extract the Me (Signed-In User). Object from Graph. Inside the User Object response I recieve, Photo and Photos property are both null.

I would appreciate it so much if someone could help me or even point me in the right direction.

Thank You.

Azure Active Directory
Azure Active Directory
An Azure enterprise identity service that provides single sign-on and multi-factor authentication.
14,892 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Vasil Michev 71,626 Reputation points MVP
    2020-06-03T16:37:37.103+00:00

    Might help if you give us an example of which exact endpoint you are querying. The examples from the documentation work just fine for me: https://learn.microsoft.com/en-us/graph/api/profilephoto-get?view=graph-rest-1.0

    Do note that only Azure AD/OrgID accounts are supported.

    0 comments No comments

  2. IT Tech Consulting 1 Reputation point
    2020-06-03T17:19:20.73+00:00

    I have AzureAD Accounts with trying to hit https://graph.microsoft.com/v1.0.

    I'm using the example ubiquitous:

    {
                        // Get user photo
                        using var photoStream = await graphClient.Me.Photo.Content.Request().GetAsync();
                        byte[] photoByte = ((MemoryStream)photoStream).ToArray();
                        ViewData["Photo"] = Convert.ToBase64String(photoByte);
                        HttpContext.Session.SetString("PhString", ViewData["Photo"].ToString());
                    }
                    catch (System.Exception)
                    {
                        ViewData["Photo"] = null;
                    }
    
    }
    

    I get the system exception everytime. In Graph Explorer, after login in as the AD User. Calls recieve:

    {
        "error": {
            "code": "OrganizationFromTenantGuidNotFound",
            "message": "The tenant for tenant guid '734a0293-a586-44fa-b728-43b06ef11410' does not exist.",
            "innerError": {
                "request-id": "6864e68b-6eec-4aed-a14e-c29fdac626fc",
                "date": "2020-06-03T17:18:40"
            }
        }
    }
    
    0 comments No comments