microsoftgraph / aspnet-snippets-sample

A repository of code snippets that use Microsoft Graph to perform common tasks such as sending email, managing groups, and other activities from an ASP.NET Core MVC app. This sample uses the Microsoft Graph .NET Client Library to work with data, and the Microsoft Identity Web Library for authentication on the Microsoft identity platform v2.0 endpoint.
MIT License
189 stars 101 forks source link

Authentication Error - Value cannot be null. (Parameter 'value') #62

Closed andrewbaker-uk closed 3 years ago

andrewbaker-uk commented 3 years ago

Describe the bug Authentication Error - Value cannot be null. (Parameter 'value') seen on sign in after following steps in readme.md

image

To Reproduce Steps to reproduce the behavior:

  1. Follow readme.md
  2. Navigate to https://localhost:5001
  3. Sign in with Azure AD account
  4. See error

Expected behavior

  1. Follow readme.md
  2. Navigate to https://localhost:5001
  3. Sign in with Azure AD account
  4. Access app as intended

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Dependency versions

jasonjoh commented 3 years ago

Thanks for reporting. This sample does need an update as the authentication libraries have been significantly re-worked since this was last touched. However it should still work.

Can you check something for me? Can you go to Graph Explorer, login with the same account you're using to reproduce this, and run a GET https://graph.microsoft.com/v1.0/me/mailboxsettings? If that works, do you see a value for timeZone? You may see it inside workingHours or automaticRepliesSetting, but specifically I'm looking to see if it's set at the top level (like the third line below).

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('xxx')/mailboxSettings(timeZone)",
    "archiveFolder": "AAMkAGVl...AAA=",
    "timeZone": "Eastern Standard Time",
    "delegateMeetingMessageDeliveryOptions": "sendToDelegateAndPrincipal",
    "dateFormat": "",
    "timeFormat": "",
    "automaticRepliesSetting": {
        "status": "disabled",
        "externalAudience": "none",
        "internalReplyMessage": "",
        "externalReplyMessage": "",
        "scheduledStartDateTime": {
            "dateTime": "2021-02-25T20:00:00.0000000",
            "timeZone": "UTC"
        },
        "scheduledEndDateTime": {
            "dateTime": "2021-02-26T20:00:00.0000000",
            "timeZone": "UTC"
        }
    },
    "language": {
        "locale": "en-US",
        "displayName": "English (United States)"
    },
    "workingHours": {
        "daysOfWeek": [
            "monday",
            "tuesday",
            "wednesday",
            "thursday",
            "friday"
        ],
        "startTime": "09:00:00.0000000",
        "endTime": "17:00:00.0000000",
        "timeZone": {
            "name": "Eastern Standard Time"
        }
    }
}
andrewbaker-uk commented 3 years ago

Ahh this is slightly embarrassing. I'm using a Office 365 Developer account and I hadn't yet accessed the mailbox.

I didn't have an value for timeZone on the top level like in the example. As soon as I went to the mailbox and tried again, the value was populated :)

Thanks for the help

jasonjoh commented 3 years ago

Thanks for confirming! I suspected this was the case as someone else had a similar issue with the tutorial that this is based off of. The fix hasn't come over to this repo yet :D.