microsoft/teams.net

Public

mirrored fromhttps://github.com/microsoft/teams.netAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
samples/migration-bot

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

Libraries/Microsoft.Teams.Api/Clients/BotSignInClient.cs

69lines · modecode

1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT License.
3
4using Microsoft.Teams.Common.Http;
5
6namespace Microsoft.Teams.Api.Clients;
7
8public class BotSignInClient : Client
9{
10 public BotSignInClient() : base()
11 {
12
13 }
14
15 public BotSignInClient(IHttpClient client, CancellationToken cancellationToken = default) : base(client, cancellationToken)
16 {
17
18 }
19
20 public BotSignInClient(IHttpClientOptions options, CancellationToken cancellationToken = default) : base(options, cancellationToken)
21 {
22
23 }
24
25 public BotSignInClient(IHttpClientFactory factory, CancellationToken cancellationToken = default) : base(factory, cancellationToken)
26 {
27
28 }
29
30 public async Task<string> GetUrlAsync(GetUrlRequest request, CancellationToken cancellationToken = default)
31 {
32 var token = cancellationToken != default ? cancellationToken : _cancellationToken;
33 var query = QueryString.Serialize(request);
34 var req = HttpRequest.Get(
35 $"https://token.botframework.com/api/botsignin/GetSignInUrl?{query}"
36 );
37
38 var res = await _http.SendAsync(req, token);
39 return res.Body;
40 }
41
42 public async Task<SignIn.UrlResponse> GetResourceAsync(GetResourceRequest request, CancellationToken cancellationToken = default)
43 {
44 var token = cancellationToken != default ? cancellationToken : _cancellationToken;
45 var query = QueryString.Serialize(request);
46 var req = HttpRequest.Get(
47 $"https://token.botframework.com/api/botsignin/GetSignInResource?{query}"
48 );
49
50 var res = await _http.SendAsync<SignIn.UrlResponse>(req, token);
51 return res.Body;
52 }
53
54 public class GetUrlRequest
55 {
56 public required string State { get; set; }
57 public string? CodeChallenge { get; set; }
58 public string? EmulatorUrl { get; set; }
59 public string? FinalRedirect { get; set; }
60 }
61
62 public class GetResourceRequest
63 {
64 public required string State { get; set; }
65 public string? CodeChallenge { get; set; }
66 public string? EmulatorUrl { get; set; }
67 public string? FinalRedirect { get; set; }
68 }
69}