0
votes

I am new to Office 365 api. I got online and tried to used the microsoft virtual academy and other similar to it. I followed the direction from this site linkhttps://msdn.microsoft.com/office/office365/howto/authenticate-and-use-services; step for step, but I am getting an error that looks like thisError message

The steps are not hard at all. When I go into debug mode these two lines always come back null. There is very little information out there about these two lines.

var signInUserId=ClaimsPrincipal.Current.FindFirst(ClaimTypes.Email).Value; var userObjectId = ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value;

If you are looking for my code it is provided in the link I gave above. Those are all my files. To the T. Thanks in advance for any help.

Question 1. Do anyone have better resources other than the ones I am using Question 2. Can those lines be null. Question 3. Where can I find a SOLID tutorial online that works 100%

1
string userObjectID = (User.FindFirst("http ://schemas.microsoft.com/identity/claims/objectidentifier"))?.Value; Try this.Patrick Mcvay

1 Answers

0
votes

The error is because that there is no “mail” type data in the claims. To construct the AuthenticationContext object, we should use the ‘ClaimTypes.NameIdentifier’ as the ’signInUserId’ instead of ‘ClaimTypes.Email’.

And you can refer to the whole sample code from here.