-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServices.cs
More file actions
51 lines (44 loc) · 1.55 KB
/
Copy pathServices.cs
File metadata and controls
51 lines (44 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using ShapeDiver.SDK;
using ShapeDiver.SDK.Authentication;
using ShapeDiver.SDK.GeometryBackend;
using System;
using System.Threading.Tasks;
namespace StargateDotNetClientExample
{
internal class Services : IServices
{
public Services()
{
}
public async Task<bool> Init()
{
LogMessage("Authenticating user via ShapeDiver Platform...");
var sdk = new ShapeDiverSDK(clientId: "B396F50E-51F0-49CC-9D47-1A1E3E811972");
try
{
var response = await sdk.AuthenticationClient.AuthenticateViaPlatform();
LogMessage($"Success. Id of authenticated user: {sdk.AuthenticationClient.GetUserId()}");
}
catch (AuthenticationError e)
{
LogMessage($"Could not authenticate user (ShapeDiver AuthenticationError): {e}");
return false;
}
catch (Exception e)
{
LogMessage($"Could not authenticate user (Generic exception): {e}");
return false;
}
this.Sdk = sdk;
this.GeometryBackendContextCache = new GeometryBackendContextCache(sdk);
return true;
}
public IShapeDiverSDK Sdk { get; private set; }
public IGeometryBackendContextCache GeometryBackendContextCache { get; private set; }
public void LogMessage(string message)
{
var now = DateTime.UtcNow;
Console.WriteLine($"{now.ToString("o")}: {message}");
}
}
}