Eosu 404 auth token reauth p2p disconnects#1237
Eosu 404 auth token reauth p2p disconnects#1237JessTello wants to merge 4 commits intorelease-6.0.2from
Conversation
[Public] Release 6.0.0
- Added Connect AuthExpiration notify registration with minimal diagnostic logging - Cached the last Connect LoginOptions and credential type to support safe re-auth attempts - Implemented PUID change detection to log when the ProductUserId remains stable or changes mid-session - Introduced a reauth-in-progress guard to prevent concurrent Connect.Login storms during token refresh - Added a debug hook to force a Connect re-login using a fresh Epic IdToken (CopyIdToken -> Connect.Login)
| ConfigureConnectStatusCallback(); | ||
| ConfigureConnectExpirationCallback(connectLoginOptions); | ||
| ConfigureConnectExpirationCallback(); | ||
| OnConnectLogin?.Invoke(connectLoginData); |
There was a problem hiding this comment.
Moving the OnConnectLogin call into the finally block also cleans up the code above and is a nice way to make sure it's always called
There was a problem hiding this comment.
I centralized onloginCallback into the finally to guarantee single delivery. For OnConnectLogin, I kept the explicit invokes in each outcome branch to preserve the early-return flow and clarity, but I can refactor it into the finally as well (single invoke) if you prefer.
There was a problem hiding this comment.
In this case my thinking is mostly around ensuring that the callback is always called, as people can forget to call callbacks. Moving it into the finally block is the safest way to do that
|
|
||
|
|
| { | ||
| Debug.LogWarning( | ||
| $"{nameof(EOSManager)} Connect auth expired but last credential type was {s_lastConnectCredentialType}. " + | ||
| $"Plugin cannot refresh that token automatically. Game should re-fetch external token and call StartConnectLoginWithOptions again."); |
There was a problem hiding this comment.
Is there documentation for this? It's a bit of an unusual case where it handles it in certain circumstances
There was a problem hiding this comment.
Added handling for auth-expiration by credential type: we only auto-refresh when the last Connect credential is EpicIdToken (via fresh CopyIdToken -> Connect.Login). For other credential types we log a warning and require the game to re-fetch the external token and re-initiate StartConnectLoginWithOptions.
There was a problem hiding this comment.
What I mean is that this is only something that developers will see when running the game for long enough that auth expires. Also, in a specific case the plugin is handling re-authing for them, so it would be easy for someone to miss this on other platforms. It would be good to get documentation added that covers this to avoid support tickets
| $"[EOS][PUID] changed {s_lastKnownProductUserId} => {newPuid}. " + | ||
| "This can break P2P socket mapping. Refusing to overwrite silently."); | ||
| OnConnectLogin?.Invoke(connectLoginData); | ||
| return; |
There was a problem hiding this comment.
Let's discuss this in the thread
9d7ab44 to
1fa8dd5
Compare
- Updated new diagnostics to use the Log() wrapper instead of Debug.Log - Moved OnConnectLogin call into the finally block - Prevented onLoginCallback from being called twice - Removed Debug_RefreshConnectLoginWithFreshEpicIdToken() debug helper - Fixed variable name for better readability and consistency - Added handling for auth-expiration: if credential type isn't EpicIdToken, log warning and require game to re-fetch the token. - Added safety check to prevent silently overwriting the local PUID if a different ProductUserId is returned. - Reduced duplication by making RefreshConnectLoginWithFreshEpicIdToken() reuse the StartConnectLoginWithEpicAccount() flow where applicable.
1fa8dd5 to
7da495b
Compare
| static private bool s_connectReauthInProgress = false; | ||
|
|
||
| // IMPORTANT: LoginOptions is a struct, so store it as nullable | ||
| static private Epic.OnlineServices.Connect.LoginOptions? s_lastConnectLoginOptions; |
| // --- Connect reauth hardening (prevents PUID churn / P2P route resets) --- | ||
| // NOTE: EOS callbacks are expected to run on the same thread that drives PlatformInterface.Tick(). | ||
| // In typical Unity integrations that's the main thread. We keep this as a simple guard to avoid | ||
| // reauth/login storms during token refresh. |
There was a problem hiding this comment.
Can you move this to where the variable is checked in RefreshConnectLoginWithFreshEpicIdToken()? It's more likely to be spotted there
| Log( | ||
| $"{nameof(EOSManager)} Connect auth expired but last credential type was {s_lastConnectCredentialType}. " + | ||
| "Plugin cannot refresh that token automatically. Game should re-fetch external token and call StartConnectLoginWithOptions again.", | ||
| LogType.Warning); |
There was a problem hiding this comment.
In this case it would be good to keep this logging using Debug.LogWarning as it's very infrequent and would be very useful in logs
| (ref AuthExpirationCallbackInfo callbackInfo) => | ||
| { | ||
| GetEOSConnectInterface()?.RemoveNotifyAuthExpiration(handle); | ||
| OnConnectAuthExpiration(ref callbackInfo); | ||
| }); |
There was a problem hiding this comment.
Minor thing but the args match, so you should be able to just do this
| (ref AuthExpirationCallbackInfo callbackInfo) => | |
| { | |
| GetEOSConnectInterface()?.RemoveNotifyAuthExpiration(handle); | |
| OnConnectAuthExpiration(ref callbackInfo); | |
| }); | |
| OnConnectAuthExpiration); |
|
Once requested changes are resolved, please retarget to release-6.0.2 |
…uth policy - Always invoke OnConnectLogin / onloginCallback from finally (exactly-once). - Add inline docs for auth-expiration credential policy. - Remove unused caching and minor handler cleanup
Added Connect AuthExpiration notify registration with minimal diagnostic logging