Skip to content

Commit 146f92b

Browse files
committed
Try to automatically refresh expired sessions that have refresh_token methods
1 parent f74125f commit 146f92b

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

Runtime/Game/LootLockerGameServerAPI.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,42 @@ protected override void RefreshTokenAndCompleteCall(LootLockerServerRequest cach
4343
});
4444
return;
4545
}
46+
case Platforms.AppleGameCenter:
4647
case Platforms.AppleSignIn:
48+
case Platforms.Epic:
49+
case Platforms.Google:
4750
{
51+
// The failed request isn't a refresh session request but we have a refresh token stored, so try to refresh the session automatically before failing
52+
if (!cacheServerRequest.jsonPayload.Contains("refresh_token") && !string.IsNullOrEmpty(LootLockerConfig.current.refreshToken))
53+
{
54+
switch (CurrentPlatform.Get())
55+
{
56+
case Platforms.AppleGameCenter:
57+
LootLockerSDKManager.RefreshAppleGameCenterSession(response =>
58+
{
59+
CompleteCall(cacheServerRequest, OnServerResponse, response);
60+
});
61+
return;
62+
case Platforms.AppleSignIn:
63+
LootLockerSDKManager.RefreshAppleSession(response =>
64+
{
65+
CompleteCall(cacheServerRequest, OnServerResponse, response);
66+
});
67+
return;
68+
case Platforms.Epic:
69+
LootLockerSDKManager.RefreshEpicSession(response =>
70+
{
71+
CompleteCall(cacheServerRequest, OnServerResponse, response);
72+
});
73+
return;
74+
case Platforms.Google:
75+
LootLockerSDKManager.RefreshGoogleSession(response =>
76+
{
77+
CompleteCall(cacheServerRequest, OnServerResponse, response);
78+
});
79+
return;
80+
}
81+
}
4882
LootLockerLogger.GetForLogLevel(LootLockerLogger.LogLevel.Warning)($"Token has expired, please refresh it");
4983
LootLockerResponse res = new LootLockerResponse
5084
{

0 commit comments

Comments
 (0)