# EOS: how to refresh access token? After I login, it only works for 2 hours, then the game freezes

**URL:** <https://forums.unrealengine.com/t/eos-how-to-refresh-access-token-after-i-login-it-only-works-for-2-hours-then-the-game-freezes/1163637>\
**Category:** Multiplayer & Networking\
**Tags:** onlinesubsystem, online, unreal-engine, Multiplayer, CPP, question\
**Created:** [May 12, 2023, 2:47pm UTC](https://forums.unrealengine.com/t/eos-how-to-refresh-access-token-after-i-login-it-only-works-for-2-hours-then-the-game-freezes/1163637 "2023-05-12T14:47:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JediKnightChan](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jediknightchan/32/1156960_2.png) [@JediKnightChan](https://forums.unrealengine.com/u/JediKnightChan)\
**Post date:** [May 12, 2023, 2:47pm UTC](https://forums.unrealengine.com/t/eos-how-to-refresh-access-token-after-i-login-it-only-works-for-2-hours-then-the-game-freezes/1163637/1 "2023-05-12T14:47:46Z")

</div>

```auto
void UECROnlineSubsystem::Login(FString PlayerName, FString LoginType, FString Id, FString Token, bool bWantsCallback)
{
	// Setting player display name
	UserDisplayName = PlayerName;

	// Login
	if (OnlineSubsystem)
	{
		if (const IOnlineIdentityPtr OnlineIdentityPtr = OnlineSubsystem->GetIdentityInterface())
		{
			FOnlineAccountCredentials OnlineAccountCredentials;
			OnlineAccountCredentials.Id = Id;
			OnlineAccountCredentials.Token = Token;
			OnlineAccountCredentials.Type = LoginType;

			if (bWantsCallback)
			{
				OnlineIdentityPtr->OnLoginCompleteDelegates->AddUObject(this, &UECROnlineSubsystem::OnLoginComplete);
			}
			OnlineIdentityPtr->Login(0, OnlineAccountCredentials);
		}
	}
}

```

Then I usually login via accountportal

`Login(PlayerName, "accountportal");`

But in logs I see that access token works only for 2 hours. After that the game usually freezes.

`LogEOSAuth: NewUserToken: User ClientId: ... AccountId: .... Access[Expires: 2023.05.10-20.41.16 Remaining: 7200.71] Refresh[Expires: 2023-11-06T18:41:16.715Z Remaining: 15552000.71] State: Valid`  
…  
`[2023.05.10-19.40.15:439][120]LogOnline: Error: EOS: ConnectLoginNoEAS(0) failed due to no platform OSS [2023.05.10-19.40.15:439][120]LogOnline: Error: EOS: ConnectLoginNoEAS(0) failed due to the platform OSS giving an empty auth token `

How can I use the refresh token to update the access token with the OnlineSubsystem? Or maybe it should be done automatically then why it doesn’t happen?

Config is

```auto
[/Script/OnlineSubsystemEOS.EOSSettings]
CacheDir = CacheDir
DefaultArtifactName = DefaultArtifact
TickBudgetInMilliseconds = 0
bEnableOverlay = False
bEnableSocialOverlay = False
bShouldEnforceBeingLaunchedByEGS = False
TitleStorageReadChunkLength = 0
+Artifacts = (ArtifactName="DefaultArtifact",ClientId="...",ClientSecret="....",ProductId="....",SandboxId="...",DeploymentId="....",EncryptionKey="...")
bUseEAS = False
bUseEOSConnect = False
bMirrorStatsToEOS = False
bMirrorAchievementsToEOS = False
bUseEOSSessions = False
bMirrorPresenceToEAS = False

[OnlineSubsystemEOS]
bEnabled=true

[OnlineSubsystem]
DefaultPlatformService=EOS

[/Script/Engine.GameEngine]
+NetDriverDefinitions = (DefName="GameNetDriver",DriverClassName="OnlineSubsystemEOS.NetDriverEOS",DriverClassNameFallback="OnlineSubsystemUtils.IpNetDriver")

[/Script/OnlineSubsystemEOS.NetDriverEOS]
bIsUsingP2PSockets=true

```

---

<div class="post-metadata">

**Author:** ![JediKnightChan](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jediknightchan/32/1156960_2.png) [@JediKnightChan](https://forums.unrealengine.com/u/JediKnightChan)\
**Post date:** [May 15, 2023, 12:01am UTC](https://forums.unrealengine.com/t/eos-how-to-refresh-access-token-after-i-login-it-only-works-for-2-hours-then-the-game-freezes/1163637/2 "2023-05-15T00:01:01Z")

</div>

> [@JediKnightChan](#):
>
> ```auto
> [/Script/OnlineSubsystemEOS.EOSSettings]
> CacheDir = CacheDir
> DefaultArtifactName = DefaultArtifact
> TickBudgetInMilliseconds = 0
> bEnableOverlay = False
> bEnableSocialOverlay = False
> bShouldEnforceBeingLaunchedByEGS = False
> TitleStorageReadChunkLength = 0
> +Artifacts = (ArtifactName="DefaultArtifact",ClientId="...",ClientSecret="....",ProductId="....",SandboxId="...",DeploymentId="....",EncryptionKey="...")
> bUseEAS = False
> bUseEOSConnect = False
> bMirrorStatsToEOS = False
> bMirrorAchievementsToEOS = False
> bUseEOSSessions = False
> bMirrorPresenceToEAS = False
> 
> [OnlineSubsystemEOS]
> bEnabled=true
> 
> [OnlineSubsystem]
> DefaultPlatformService=EOS
> 
> [/Script/Engine.GameEngine]
> +NetDriverDefinitions = (DefName="GameNetDriver",DriverClassName="OnlineSubsystemEOS.NetDriverEOS",DriverClassNameFallback="OnlineSubsystemUtils.IpNetDriver")
> 
> [/Script/OnlineSubsystemEOS.NetDriverEOS]
> bIsUsingP2PSockets=true
> 
> ```

Need to change `bUseEAS` from `False` to `True` and add `NativePlatformService=EOS` to `[OnlineSubsystem]`

---

<div class="post-metadata">

**Author:** ![tlemsani-achref](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@tlemsani-achref](https://forums.unrealengine.com/u/tlemsani-achref)\
**Post date:** [June 7, 2024, 10:58pm UTC](https://forums.unrealengine.com/t/eos-how-to-refresh-access-token-after-i-login-it-only-works-for-2-hours-then-the-game-freezes/1163637/3 "2024-06-07T22:58:34Z")

</div>

hey , wan’t to login my players using access token of epic games ,  
i already can get the access token prom player after they login but i don’t know how to use it for login

note : (i can’t use the normal method because i am targeting android and when i trigger login in android they redirect me to the browser which cause the game to quit (for players with low end deivices ) so i wan’t make custom webview inside my gaame for login and getting the access token ) sorry for that long note =(
