microsoftgraph / microsoftgraph/msgraph-sdk-dotnet

TemporaryAccessPassMethods : Invalid StartDateTime depending on local computer timezone

Open
#2,724 3 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Status: Needs investigation type:bug
Dominant language
C#
Stars
789
Forks
264
Avg merge
15h 17m
Merged PRs (30d)
3

Description

Describe the bug

I'm trying to create a temporary access pass (TAP) for a user and specify the start date time of the TAP but I get the following error message : "One or more errors occurred. (Invalid StartDateTime specified. It can not be a time in the past.)"

My local time zone is UTC +1 (Brussels).
If I add an offset of 7 hours (less doesn't work), the TAP is created successfully but the activation date is 7 hours from now.
If I set my local computer time zone to something else without an offset, I have the same error message.
If I set my local computer time zone to UTC -6 and add an offset of 7 hours, the TAP is created and the activation date is now correct.
If I manually specify the time to be "Now + 5 minutes", I have the same error message. If I manually specify the time to be "Now + 7 hours", it works but with activation date in 7 hours.

Expected behavior

A temporary access pass should be created for the user with an activation time/date matching the specified DateTimeOffset.

How to reproduce

DateTimeOffset startDateTime = DateTimeOffset.Now;
var requestBody = new TemporaryAccessPassAuthenticationMethod
{
StartDateTime = startDateTime,
LifetimeInMinutes = 60,
IsUsableOnce = false,
};

using (var task = Task.Run(async () => await graphClient.Users[currentUserID]
.Authentication
.TemporaryAccessPassMethods.PostAsync(requestBody)))
{
while (!task.IsCompleted)
Thread.Sleep(200);
if (task.IsFaulted)
{
return task.Exception.Message;
}
return task.Result.TemporaryAccessPass;

SDK Version

5.59.0

Latest version known to work for scenario above?

No response

Known Workarounds

Set your local computer's time zone to [Your time zone -6] and add an offset of +7 hours.

Debug output
Click to expand log ```

Exception thrown: 'Microsoft.Graph.Models.ODataErrors.ODataError' in System.Private.CoreLib.dll

</details>


### Configuration

Windows 11, x64

### Other information

_No response_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the supplied C# reproduction using DateTimeOffset.Now and TemporaryAccessPassAuthenticationMethod through the users authentication TemporaryAccessPassMethods.PostAsync entry point. Compare the serialized startDateTime value and the service response across time zones; done means the requested DateTimeOffset is accepted and the activation time matches it.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.