Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

Use correct platform API endpoint for DAT in Deployment Launcher #1366

Merged
merged 2 commits into from
May 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- Invalid JSON is now logged if there is an error parsing the codegen output. [#1353](https://github.com/spatialos/gdk-for-unity/pull/1353)
- The Mobile Launcher will no longer break if Android build support is not installed. [#1354](https://github.com/spatialos/gdk-for-unity/pull/1354)
- Fixed a bug in the `EntityTemplate` class where calling `AddComponent` with an `EntityAcl.Snapshot` would incorrectly apply its write access [#1360](https://github.com/spatialos/gdk-for-unity/pull/1360)
- The Deployment Launcher will now generate Dev Auth Tokens using the environment specified in the GDK Tools Configuration. [#1366](https://github.com/spatialos/gdk-for-unity/pull/1366)

### Internal

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using Improbable.SpatialOS.Deployment.V1Alpha1;
using Improbable.SpatialOS.Platform.Common;
using Improbable.SpatialOS.PlayerAuth.V2Alpha1;
using Improbable.SpatialOS.Snapshot.V1Alpha1;

namespace Improbable.Gdk.DeploymentLauncher
Expand All @@ -13,14 +14,24 @@ public static DeploymentServiceClient CreateDeploymentClient(Options.Common opti
{
return string.IsNullOrEmpty(options.Environment)
? DeploymentServiceClient.Create()
: DeploymentServiceClient.Create(GetEndpoint(options.Environment), GetTokenCredential(options.Environment));
: DeploymentServiceClient.Create(GetEndpoint(options.Environment),
GetTokenCredential(options.Environment));
}

public static SnapshotServiceClient CreateSnapshotClient(Options.Common options)
{
return string.IsNullOrEmpty(options.Environment)
? SnapshotServiceClient.Create()
: SnapshotServiceClient.Create(GetEndpoint(options.Environment), GetTokenCredential(options.Environment));
: SnapshotServiceClient.Create(GetEndpoint(options.Environment),
GetTokenCredential(options.Environment));
}

public static PlayerAuthServiceClient CreatePlayerAuthClient(Options.Common options)
{
return string.IsNullOrEmpty(options.Environment)
? PlayerAuthServiceClient.Create()
: PlayerAuthServiceClient.Create(GetEndpoint(options.Environment),
GetTokenCredential(options.Environment));
}

private static PlatformApiEndpoint GetEndpoint(string environment)
Expand Down Expand Up @@ -54,8 +65,10 @@ private static string GetRefreshToken(string environment)
var possibleTokenFiles = new[]
{
Environment.GetEnvironmentVariable("SPATIALOS_REFRESH_TOKEN_FILE"),
Path.Combine(Environment.GetEnvironmentVariable("HOME") ?? "", $".improbable/oauth2/oauth2_refresh_token_{environment}"),
Path.Combine(Environment.ExpandEnvironmentVariables("%LOCALAPPDATA%"), $".improbable/oauth2/oauth2_refresh_token_{environment}")
Path.Combine(Environment.GetEnvironmentVariable("HOME") ?? "",
$".improbable/oauth2/oauth2_refresh_token_{environment}"),
Path.Combine(Environment.ExpandEnvironmentVariables("%LOCALAPPDATA%"),
$".improbable/oauth2/oauth2_refresh_token_{environment}")
};

var tokenFile = possibleTokenFiles.FirstOrDefault(File.Exists);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private static int CreateDeploymentInternal<TOptions>(TOptions options, Func<TOp

private static string ModifySimulatedPlayerLaunchJson(Options.CreateSimulated options)
{
var playerAuthServiceClient = PlayerAuthServiceClient.Create();
var playerAuthServiceClient = ClientFactory.CreatePlayerAuthClient(options);

// Create development authentication token used by the simulated players.
var dat = playerAuthServiceClient.CreateDevelopmentAuthenticationToken(
Expand Down