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

Commit

Permalink
Use correct platform API endpoint for DAT in Deployment Launcher (#1366)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Brynes authored May 20, 2020
1 parent 0266b65 commit 54bbedb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
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

0 comments on commit 54bbedb

Please sign in to comment.