Skip to content

Comments

Eosu 404 auth token reauth p2p disconnects#1237

Open
JessTello wants to merge 3 commits intorelease-6.0.1from
eosu-404-auth-token-reauth-p2p-disconnects
Open

Eosu 404 auth token reauth p2p disconnects#1237
JessTello wants to merge 3 commits intorelease-6.0.1from
eosu-404-auth-token-reauth-p2p-disconnects

Conversation

@JessTello
Copy link
Contributor

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)

DanF-ApexSystems and others added 2 commits February 10, 2026 11:05
- 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)
{
Log($"Connect login was not successful. ResultCode: {connectLoginData.ResultCode}", LogType.Error);
OnConnectLogin?.Invoke(connectLoginData);
onloginCallback?.Invoke(connectLoginData);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this here onLoginCallback would be called twice (bc it's also in the finally block)

Suggested change
onloginCallback?.Invoke(connectLoginData);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the next commit. I removed the extra onloginCallback?.Invoke()

public void StartConnectLoginWithOptions(Epic.OnlineServices.Connect.LoginOptions connectLoginOptions,
OnConnectLoginCallback onloginCallback)
{
Debug.Log($"[EOS][ConnectLogin] t={Time.realtimeSinceStartup:F1} puid(prev)={s_lastKnownProductUserId} cred={s_lastConnectCredentialType}");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logging in this file should use the Log() function because it's conditionally compiled out with the ENABLE_DEBUG_EOSMANAGER flag

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the next commit. I switched to using the Log() wrapper instead of Debug.Log

ConfigureConnectStatusCallback();
ConfigureConnectExpirationCallback(connectLoginOptions);
ConfigureConnectExpirationCallback();
OnConnectLogin?.Invoke(connectLoginData);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

public void StartConnectLoginWithOptions(Epic.OnlineServices.Connect.LoginOptions connectLoginOptions,
OnConnectLoginCallback onloginCallback)
{
Debug.Log($"[EOS][ConnectLogin] t={Time.realtimeSinceStartup:F1} puid(prev)={s_lastKnownProductUserId} cred={s_lastConnectCredentialType}");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't log PUID/Epic account ids, created a thread to discuss this further

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in the next commit the remaining PUID/EAS identifier logs (including the legacy SetLocalProductUserId() message) so no user IDs are printed.

Comment on lines 1394 to 1397
var EOSConnectInterface = GetEOSConnectInterface();
var addNotifyAuthExpirationOptions = new AddNotifyAuthExpirationOptions();

ulong callbackHandle = EOSConnectInterface.AddNotifyAuthExpiration(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not your change but we might as well fix the var name whilst here

Suggested change
var EOSConnectInterface = GetEOSConnectInterface();
var addNotifyAuthExpirationOptions = new AddNotifyAuthExpirationOptions();
ulong callbackHandle = EOSConnectInterface.AddNotifyAuthExpiration(
var eosConnectInterface = GetEOSConnectInterface();
var addNotifyAuthExpirationOptions = new AddNotifyAuthExpirationOptions();
ulong callbackHandle = eosConnectInterface.AddNotifyAuthExpiration(

Comment on lines +1410 to +1411


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Comment on lines 2004 to 2006
///


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
///

{
Debug.Log("[EOS][ReauthTest] Manual reauth triggered");
RefreshConnectLoginWithFreshEpicIdToken();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test function needs removing (at least it appears to be unused)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

{
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.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there documentation for this? It's a bit of an unusual case where it handles it in certain circumstances

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

$"[EOS][PUID] changed {s_lastKnownProductUserId} => {newPuid}. " +
"This can break P2P socket mapping. Refusing to overwrite silently.");
OnConnectLogin?.Invoke(connectLoginData);
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's discuss this in the thread

private void OnConnectAuthExpiration(ref AuthExpirationCallbackInfo callbackInfo)
{
Debug.Log($"[EOS][AuthExp] fired t={Time.realtimeSinceStartup:F1} puid={s_lastKnownProductUserId} cred={s_lastConnectCredentialType}");
lock (s_connectReauthLock)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code should be always running on the main thread anyway because all callbacks will be fired from the thread where PlatformInterface.Tick() is called. Was this a safety measure or did that not happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the lock and replaced it with a simple reauth-in-progress guard to prevent concurrent reauth storms.

}


private void RefreshConnectLoginWithFreshEpicIdToken()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code in this function overlaps a lot with what's in StartConnectLoginWithEpicAccount().
With a little work you should be able to move most of the logic in that function to a new one and re-use it here? The other function is async but it could call GetUserLoginInfo upfront, so no issues there

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed on the overlap. Since StartConnectLoginWithEpicAccount() already performs the fresh IdToken + Connect.Login flow, I updated RefreshConnectLoginWithFreshEpicIdToken() to be a thin wrapper that reuses that existing codepath (silent, no callback) and keeps the reauth-in-progress guard.

@JessTello JessTello force-pushed the eosu-404-auth-token-reauth-p2p-disconnects branch from 9d7ab44 to 1fa8dd5 Compare February 21, 2026 00:57
- 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.
@JessTello JessTello force-pushed the eosu-404-auth-token-reauth-p2p-disconnects branch from 1fa8dd5 to 7da495b Compare February 21, 2026 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants