1
votes

I'm getting an "ErrorAccessDenied" when attempting to get user photos with the Microsoft Graph API v1.0.

I can get a user's information by using

var user = graphClient.Users["userprincipalname"].Request().GetAsync();

And I am also able to use

"https://graph.microsoft.com/v1.0/users/userprincipalname/photo/$value"

In Microsoft's graph explorer to get a user's photo

However when I try to use

var user = graphClient.Users["userprincipalname"].Photo.Content.Request().GetAsync();

I get

{Code: ErrorAccessDenied
Message: Access is denied. Check credentials and try again. Inner error
}   

But I'm pretty sure my credentials are correct as I could get all the other information regarding the user. My app is registered in Azure Portal and uses the v1.0 endpoint if that helps.

Any help is appreciated, thanks!

1
Is you application authenticating using the same creds that you use when testing in the graph explorer?JTW
What permissions is you app asking for when requesting the OAuth token?Venkat Ayyadevara - MSFT
@VenkatAyyadevara-MSFT in the Azure portal, I set the application's permissions for User.ReadBasic.All, Directory.Read.All, User.Read.All for both application permission and delegate permissionyfan183
@yfan183 Thanks for the info. Can you please provide a sample response including header that provides the request ID?Venkat Ayyadevara - MSFT
Also please make sure that the user has consented the app after you added the permissions.Yina - MSFT

1 Answers

0
votes

If application permissions were updated after the user consented, a re-consent is needed. To force showing consent dialog to user, include prompt=consent query parameter to /authorize request. Example:https://login.microsoftonline.com/common/oauth2/authorize?prompt=consent