A game about forced loneliness, made by TACStudios
1using System;
2
3using UnityEngine;
4
5using Codice.CM.Common;
6using Codice.LogWrapper;
7using PlasticGui;
8using Unity.PlasticSCM.Editor.WebApi;
9
10namespace Unity.PlasticSCM.Editor.Configuration
11{
12 internal static class AutoConfig
13 {
14 internal static TokenExchangeResponse PlasticCredentials(
15 string unityAccessToken,
16 string serverName)
17 {
18 var startTick = Environment.TickCount;
19
20 var tokenExchangeResponse = WebRestApiClient.PlasticScm.TokenExchange(unityAccessToken);
21
22 mLog.DebugFormat("TokenExchange time {0} ms", Environment.TickCount - startTick);
23
24 if (tokenExchangeResponse == null)
25 {
26 var warning = PlasticLocalization.GetString(PlasticLocalization.Name.TokenExchangeResponseNull);
27 mLog.Warn(warning);
28 Debug.LogWarning(warning);
29 return null;
30 }
31
32 if (tokenExchangeResponse.Error != null)
33 {
34 var warning = string.Format(
35 PlasticLocalization.GetString(PlasticLocalization.Name.TokenExchangeResponseError),
36 tokenExchangeResponse.Error.Message, tokenExchangeResponse.Error.ErrorCode);
37 mLog.ErrorFormat(warning);
38 Debug.LogWarning(warning);
39 return tokenExchangeResponse;
40 }
41
42 if (string.IsNullOrEmpty(tokenExchangeResponse.AccessToken))
43 {
44 var warning = string.Format(
45 PlasticLocalization.GetString(PlasticLocalization.Name.TokenExchangeAccessEmpty),
46 tokenExchangeResponse.User);
47 mLog.InfoFormat(warning);
48 Debug.LogWarning(warning);
49 return tokenExchangeResponse;
50 }
51
52 ClientConfiguration.Save(
53 serverName,
54 SEIDWorkingMode.SSOWorkingMode,
55 tokenExchangeResponse.User,
56 tokenExchangeResponse.AccessToken);
57
58 return tokenExchangeResponse;
59 }
60
61 static readonly ILog mLog = PlasticApp.GetLogger("AutoConfig");
62 }
63}
64