Question with Authentication Failure with Adjusted Device Time

Hello Unity Community,

I've run into something with Unity Authentication. It seems to fail when my device's time is set either 2 days forward or backward. Is this a known security feature? Any insights would be really helpful. Thanks!

What version of Authentication are you using?
We removed time validation in version 2.5.0 and above.

Auth: 3.1.0
Unity: 2022.3.14f1

I set the date to Dec 3, two days backward, and got these error messages, both on macOS and android phone. It works fine if I set the date back to Dec 5.

Error Log:

Curl error 56: CONNECT tunnel failed, response 503

0 GetStacktrace(int)

1 DebugStringToFile(DebugStringToFileData const&)

2 TransformCurlErrorToWebError(CURLcode, char*, bool)

3 CurlExecutor::CurlExecute()

4 ujob_execute_job(ujob_control_t*, ujob_lane_t*, ujob_job_t*, ujob_handle_t, unsigned int)

5 lane_guts(ujob_control_t*, ujob_lane_t*, int, int)

6 worker_thread_routine(void*)

7 Thread::RunThreadWrapper(void*)

8 _pthread_start

9 thread_start

Unity.Services.Core.RequestFailedException: Network Error: Failed to receive data ---> Unity.Services.Authentication.WebRequestException: Failed to receive data
at Unity.Services.Authentication.WebRequest.SendAsyncT [0x00025] in ./Library/PackageCache/com.unity.services.authentication@3.1.0/Runtime/Network/WebRequest.cs:45
at Unity.Services.Authentication.AuthenticationServiceInternal.HandleSignInRequestAsync (System.Func`1[TResult] signInRequest, System.Boolean enableRefresh) [0x00036] in ./Library/PackageCache/com.unity.services.authentication@3.1.0/Runtime/AuthenticationServiceInternal.cs:267
--- End of inner exception stack trace ---

0 GetStacktrace(int)

1 DebugStringToFile(DebugStringToFileData const&)

2 DebugLogHandler_CUSTOM_Internal_Log(LogType, LogOption, ScriptingBackendNativeStringPtrOpaque*, ScriptingBackendNativeObjectPtrOpaque*)

3 (Mono JIT Code) (wrapper managed-to-native) UnityEngine.DebugLogHandler:Internal_Log (UnityEngine.LogType,UnityEngine.LogOption,string,UnityEngine.Object)

4 (Mono JIT Code) [DebugLogHandler.cs:9] UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[ ])

5 (Mono JIT Code) [Logger.cs:60] UnityEngine.Logger:Log (UnityEngine.LogType,object)

6 (Mono JIT Code) [Debug.bindings.cs:130] UnityEngine.Debug:LogError (object)

7 (Mono JIT Code) [UnityAuth.cs:39] UnityAuth/<>c:b__1_1 (Unity.Services.Core.RequestFailedException)

8 (Mono JIT Code) [AuthenticationServiceInternal.cs:482] Unity.Services.Authentication.AuthenticationServiceInternal:SendSignInFailedEvent (Unity.Services.Core.RequestFailedException,bool)

9 (Mono JIT Code) [AuthenticationServiceInternal.cs:284] Unity.Services.Authentication.AuthenticationServiceInternal/d__119:MoveNext ()

10 (Mono JIT Code) System.Runtime.CompilerServices.AsyncMethodBuilderCore/MoveNextRunner:InvokeMoveNext (object)

11 (Mono JIT Code) System.Threading.ExecutionContext:RunInternal (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool)

12 (Mono JIT Code) System.Threading.ExecutionContext:Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool)

13 (Mono JIT Code) System.Runtime.CompilerServices.AsyncMethodBuilderCore/MoveNextRunner:Run ()

14 (Mono JIT Code) System.Threading.Tasks.AwaitTaskContinuation:InvokeAction (object)

15 (Mono JIT Code) System.Threading.Tasks.AwaitTaskContinuation:RunCallback (System.Threading.ContextCallback,object,System.Threading.Tasks.Task&)

16 (Mono JIT Code) System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation:Run (System.Threading.Tasks.Task,bool)

17 (Mono JIT Code) System.Threading.Tasks.Task:FinishContinuations ()

18 (Mono JIT Code) System.Threading.Tasks.Task:FinishStageThree ()

19 (Mono JIT Code) System.Threading.Tasks.Task:FinishStageTwo ()

20 (Mono JIT Code) System.Threading.Tasks.Task:Finish (bool)

21 (Mono JIT Code) System.Threading.Tasks.Task:TrySetException (object)

22 (Mono JIT Code) System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetException (System.Exception)

23 (Mono JIT Code) [WebRequest.cs:63] Unity.Services.Authentication.WebRequest/d__15`1:MoveNext ()

24 (Mono JIT Code) System.Runtime.CompilerServices.AsyncMethodBuilderCore/MoveNextRunner:InvokeMoveNext (object)

25 (Mono JIT Code) System.Threading.ExecutionContext:RunInternal (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool)

26 (Mono JIT Code) System.Threading.ExecutionContext:Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool)

27 (Mono JIT Code) System.Runtime.CompilerServices.AsyncMethodBuilderCore/MoveNextRunner:Run ()

28 (Mono JIT Code) System.Threading.Tasks.AwaitTaskContinuation:InvokeAction (object)

29 (Mono JIT Code) System.Threading.Tasks.AwaitTaskContinuation:RunCallback (System.Threading.ContextCallback,object,System.Threading.Tasks.Task&)

30 (Mono JIT Code) System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation:Run (System.Threading.Tasks.Task,bool)

31 (Mono JIT Code) System.Threading.Tasks.Task:FinishContinuations ()

32 (Mono JIT Code) System.Threading.Tasks.Task:FinishStageThree ()

33 (Mono JIT Code) System.Threading.Tasks.Task:FinishStageTwo ()

34 (Mono JIT Code) System.Threading.Tasks.Task:Finish (bool)

35 (Mono JIT Code) System.Threading.Tasks.Task:TrySetException (object)

36 (Mono JIT Code) System.Threading.Tasks.TaskCompletionSource`1:TrySetException (System.Exception)

37 (Mono JIT Code) System.Threading.Tasks.TaskCompletionSource`1:SetException (System.Exception)

38 (Mono JIT Code) [WebRequest.cs:193] Unity.Services.Authentication.WebRequest:RequestCompleted (System.Threading.Tasks.TaskCompletionSource1<string>,long,bool,bool,string,string,System.Collections.Generic.IDictionary2)

39 (Mono JIT Code) [WebRequest.cs:76] Unity.Services.Authentication.WebRequest/<>c_DisplayClass16_1:b_0 (UnityEngine.AsyncOperation)

40 (Mono JIT Code) [AsyncOperation.cs:21] UnityEngine.AsyncOperation:InvokeCompletionEvent ()

41 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void_this_ (object,intptr,intptr,intptr)

42 mono_jit_runtime_invoke

43 do_runtime_invoke

44 mono_runtime_invoke

45 scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool)

46 ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool)

47 AsyncOperation::InvokeCoroutine()

48 UnityWebRequestAsyncOperation::InvokeCoroutine()

49 UnityWebRequestProto::Job_InvokeCoroutine(AsyncOperation*)

50 BackgroundJobQueue::ExecuteMainThreadJobs()

51 InitPlayerLoopCallbacks()::EarlyUpdateExecuteMainThreadJobsRegistrator::Forward()

52 Application::TickTimer()

53 -[EditorApplication TickTimer]

54 __NSFireTimer

55 CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION

56 __CFRunLoopDoTimer

57 __CFRunLoopDoTimers

58 __CFRunLoopRun

59 CFRunLoopRunSpecific

60 RunCurrentEventLoopInMode

61 ReceiveNextEventCommon

62 _BlockUntilNextEventMatchingListInModeWithFilter

63 _DPSNextEvent

64 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]

65 -[NSApplication run]

66 NSApplicationMain

67 EditorMain(int, char const**)

68 main

69 ???

[Authentication]: Request failed: 0, Failed to receive data

0 GetStacktrace(int)

1 DebugStringToFile(DebugStringToFileData const&)

2 DebugLogHandler_CUSTOM_Internal_Log(LogType, LogOption, ScriptingBackendNativeStringPtrOpaque*, ScriptingBackendNativeObjectPtrOpaque*)

3 (Mono JIT Code) (wrapper managed-to-native) UnityEngine.DebugLogHandler:Internal_Log (UnityEngine.LogType,UnityEngine.LogOption,string,UnityEngine.Object)

4 (Mono JIT Code) [DebugLogHandler.cs:9] UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[ ])

5 (Mono JIT Code) [Logger.cs:90] UnityEngine.Logger:Log (string,object)

6 (Mono JIT Code) [Logger.cs:16] Unity.Services.Authentication.Logger:Log (object)

7 (Mono JIT Code) [AuthenticationExceptionHandler.cs:104] Unity.Services.Authentication.AuthenticationExceptionHandler:ConvertException (Unity.Services.Authentication.WebRequestException)

8 (Mono JIT Code) [AuthenticationServiceInternal.cs:276] Unity.Services.Authentication.AuthenticationServiceInternal/d__119:MoveNext ()

9 (Mono JIT Code) System.Runtime.CompilerServices.AsyncMethodBuilderCore/MoveNextRunner:InvokeMoveNext (object)

10 (Mono JIT Code) System.Threading.ExecutionContext:RunInternal (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool)

11 (Mono JIT Code) System.Threading.ExecutionContext:Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool)

12 (Mono JIT Code) System.Runtime.CompilerServices.AsyncMethodBuilderCore/MoveNextRunner:Run ()

13 (Mono JIT Code) System.Threading.Tasks.AwaitTaskContinuation:InvokeAction (object)

14 (Mono JIT Code) System.Threading.Tasks.AwaitTaskContinuation:RunCallback (System.Threading.ContextCallback,object,System.Threading.Tasks.Task&)

15 (Mono JIT Code) System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation:Run (System.Threading.Tasks.Task,bool)

16 (Mono JIT Code) System.Threading.Tasks.Task:FinishContinuations ()

17 (Mono JIT Code) System.Threading.Tasks.Task:FinishStageThree ()

18 (Mono JIT Code) System.Threading.Tasks.Task:FinishStageTwo ()

19 (Mono JIT Code) System.Threading.Tasks.Task:Finish (bool)

20 (Mono JIT Code) System.Threading.Tasks.Task:TrySetException (object)

21 (Mono JIT Code) System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetException (System.Exception)

22 (Mono JIT Code) [WebRequest.cs:63] Unity.Services.Authentication.WebRequest/d__15`1:MoveNext ()

23 (Mono JIT Code) System.Runtime.CompilerServices.AsyncMethodBuilderCore/MoveNextRunner:InvokeMoveNext (object)

24 (Mono JIT Code) System.Threading.ExecutionContext:RunInternal (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool)

25 (Mono JIT Code) System.Threading.ExecutionContext:Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool)

26 (Mono JIT Code) System.Runtime.CompilerServices.AsyncMethodBuilderCore/MoveNextRunner:Run ()

27 (Mono JIT Code) System.Threading.Tasks.AwaitTaskContinuation:InvokeAction (object)

28 (Mono JIT Code) System.Threading.Tasks.AwaitTaskContinuation:RunCallback (System.Threading.ContextCallback,object,System.Threading.Tasks.Task&)

29 (Mono JIT Code) System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation:Run (System.Threading.Tasks.Task,bool)

30 (Mono JIT Code) System.Threading.Tasks.Task:FinishContinuations ()

31 (Mono JIT Code) System.Threading.Tasks.Task:FinishStageThree ()

32 (Mono JIT Code) System.Threading.Tasks.Task:FinishStageTwo ()

33 (Mono JIT Code) System.Threading.Tasks.Task:Finish (bool)

34 (Mono JIT Code) System.Threading.Tasks.Task:TrySetException (object)

35 (Mono JIT Code) System.Threading.Tasks.TaskCompletionSource`1:TrySetException (System.Exception)

36 (Mono JIT Code) System.Threading.Tasks.TaskCompletionSource`1:SetException (System.Exception)

37 (Mono JIT Code) [WebRequest.cs:193] Unity.Services.Authentication.WebRequest:RequestCompleted (System.Threading.Tasks.TaskCompletionSource1<string>,long,bool,bool,string,string,System.Collections.Generic.IDictionary2)

38 (Mono JIT Code) [WebRequest.cs:76] Unity.Services.Authentication.WebRequest/<>c_DisplayClass16_1:b_0 (UnityEngine.AsyncOperation)

39 (Mono JIT Code) [AsyncOperation.cs:21] UnityEngine.AsyncOperation:InvokeCompletionEvent ()

40 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void_this_ (object,intptr,intptr,intptr)

41 mono_jit_runtime_invoke

42 do_runtime_invoke

43 mono_runtime_invoke

44 scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool)

45 ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool)

46 AsyncOperation::InvokeCoroutine()

47 UnityWebRequestAsyncOperation::InvokeCoroutine()

48 UnityWebRequestProto::Job_InvokeCoroutine(AsyncOperation*)

49 BackgroundJobQueue::ExecuteMainThreadJobs()

50 InitPlayerLoopCallbacks()::EarlyUpdateExecuteMainThreadJobsRegistrator::Forward()

51 Application::TickTimer()

52 -[EditorApplication TickTimer]

53 __NSFireTimer

54 CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION

55 __CFRunLoopDoTimer

56 __CFRunLoopDoTimers

57 __CFRunLoopRun

58 CFRunLoopRunSpecific

59 RunCurrentEventLoopInMode

60 ReceiveNextEventCommon

61 _BlockUntilNextEventMatchingListInModeWithFilter

62 _DPSNextEvent

63 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]

64 -[NSApplication run]

65 NSApplicationMain

66 EditorMain(int, char const**)

67 main

68 ???

WebRequestException: Failed to receive data
Unity.Services.Authentication.WebRequest.SendAsyncT (at ./Library/PackageCache/com.unity.services.authentication@3.1.0/Runtime/Network/WebRequest.cs:45)
Unity.Services.Authentication.AuthenticationServiceInternal.HandleSignInRequestAsync (System.Func1[TResult] signInRequest, System.Boolean enableRefresh) (at ./Library/PackageCache/com.unity.services.authentication@3.1.0/Runtime/AuthenticationServiceInternal.cs:267)
Rethrow as RequestFailedException: Network Error: Failed to receive data
Unity.Services.Authentication.AuthenticationServiceInternal.HandleSignInRequestAsync (System.Func
1[TResult] signInRequest, System.Boolean enableRefresh) (at ./Library/PackageCache/com.unity.services.authentication@3.1.0/Runtime/AuthenticationServiceInternal.cs:285)
UnityAuth.SignInAnonymouslyAsync () (at Assets/Code/SDK/UnityAuth.cs:56)
UnityEngine.Debug:LogException(Exception)
d_2:MoveNext() (at Assets/Code/SDK/UnityAuth.cs:73)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder:SetException(Exception)
Unity.Services.Authentication.d
119:MoveNext() (at ./Library/PackageCache/com.unity.services.authentication@3.1.0/Runtime/AuthenticationServiceInternal.cs:285)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetException(Exception)
Unity.Services.Authentication.d
151:MoveNext() (at ./Library/PackageCache/com.unity.services.authentication@3.1.0/Runtime/Network/WebRequest.cs:63)
System.Threading.Tasks.TaskCompletionSource
1:SetException(Exception)
Unity.Services.Authentication.WebRequest:RequestCompleted(TaskCompletionSource1, Int64, Boolean, Boolean, String, String, IDictionary2) (at ./Library/PackageCache/com.unity.services.authentication@3.1.0/Runtime/Network/WebRequest.cs:193)
Unity.Services.Authentication.<>c
DisplayClass16_1:b_0(AsyncOperation) (at ./Library/PackageCache/com.unity.services.authentication@3.1.0/Runtime/Network/WebRequest.cs:76)
UnityEngine.AsyncOperation:InvokeCompletionEvent() (at /Users/bokken/build/output/unity/unity/Runtime/Export/Scripting/AsyncOperation.cs:21)