-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIdentityManager.cs
35 lines (28 loc) · 1.17 KB
/
IdentityManager.cs
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
//-----------------------------------------------------------------------
// <copyright file="IdentityManager.cs" company="P.O.S Informatique">
// Copyright (c) P.O.S Informatique. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace PosInformatique.Azure.Communication.UI.Blazor.Demo
{
using global::Azure.Communication.Identity;
using Microsoft.Extensions.Options;
public class IdentityManager
{
private CommunicationIdentityClient client;
public IdentityManager(IOptions<IdentityManagerOptions> options)
{
this.client = new CommunicationIdentityClient(options.Value.ConnectionString);
}
public async Task<string> CreateUserAsync()
{
var response = await this.client.CreateUserAsync();
return response.Value.Id;
}
public async Task<string> GetTokenAsync(string userId)
{
var response = await this.client.GetTokenAsync(new global::Azure.Communication.CommunicationUserIdentifier(userId), [CommunicationTokenScope.VoIP]);
return response.Value.Token;
}
}
}