microsoft/teams.net

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
next/core-activitybuilder

Branches

Tags

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

Clone

HTTPS

Download ZIP

Libraries/Microsoft.Teams.Api/Auth/Token.cs

76lines · modecode

1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT License.
3
4using System.Text.Json.Serialization;
5
6namespace Microsoft.Teams.Api.Auth;
7
8/// <summary>
9/// any authorized token
10/// </summary>
11public interface IToken
12{
13 /// <summary>
14 /// the app id
15 /// </summary>
16 public string? AppId { get; }
17
18 /// <summary>
19 /// the app display name
20 /// </summary>
21 public string? AppDisplayName { get; }
22
23 /// <summary>
24 /// the tenant id
25 /// </summary>
26 public string? TenantId { get; }
27
28 /// <summary>
29 /// the service url to send responses to
30 /// </summary>
31 public string ServiceUrl { get; }
32
33 /// <summary>
34 /// where the activity originated from
35 /// </summary>
36 public CallerType From { get; }
37
38 /// <summary>
39 /// the id of the acitivity sender
40 /// </summary>
41 public string FromId { get; }
42
43 /// <summary>
44 /// the timestamp when this token expires
45 /// </summary>
46 public DateTime? Expiration { get; }
47
48 /// <summary>
49 /// check if the token is expired
50 /// </summary>
51 /// <returns>true if expired, otherwise false</returns>
52 public bool IsExpired { get; }
53
54 /// <summary>
55 /// a list of the tokens scopes
56 /// </summary>
57 public IEnumerable<string> Scopes { get; }
58
59 /// <summary>
60 /// convert the token to its string representation
61 /// </summary>
62 public string ToString();
63}
64
65[JsonConverter(typeof(JsonConverter<CallerType>))]
66public class CallerType(string value) : Common.StringEnum(value)
67{
68 public static readonly CallerType Bot = new("bot");
69 public bool IsBot => Bot.Equals(Value);
70
71 public static readonly CallerType Azure = new("azure");
72 public bool IsAzure => Azure.Equals(Value);
73
74 public static readonly CallerType Gov = new("gov");
75 public bool IsGov => Gov.Equals(Value);
76}