question

ITTechConsulting-1708 avatar image
0 Votes"
ITTechConsulting-1708 asked ITTechConsulting-1708 answered

Access AzureAD Profile Picture from MS Graph

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
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

michev avatar image
0 Votes"
michev answered

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://docs.microsoft.com/en-us/graph/api/profilephoto-get?view=graph-rest-1.0

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

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ITTechConsulting-1708 avatar image
0 Votes"
ITTechConsulting-1708 answered

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"
         }
     }
 }
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.