Microsoft.Bot.Connector.MicrosoftAppCredentials Class Reference
Inheritance diagram for Microsoft.Bot.Connector.MicrosoftAppCredentials:


class  OAuthException
class  OAuthResponse

Public Member Functions

 MicrosoftAppCredentials (string appId=null, string password=null, ILogger logger=null)
 MicrosoftAppCredentials (IConfiguration configuration, ILogger logger=null)
async Task< string > GetTokenAsync (bool forceRefresh=false)
override async Task ProcessHttpRequestAsync (HttpRequestMessage request, CancellationToken cancellationToken)
 Apply the credentials to the HTTP request. More...

Static Public Member Functions

static bool IsTrustedServiceUrl (string serviceUrl)
 Checks if the service url is for a trusted host or not. More...
static void TrustServiceUrl (string serviceUrl, DateTime expirationTime=default(DateTime))
 Adds the host of service url to MicrosoftAppCredentials trusted hosts. More...

Public Attributes

const string MicrosoftAppIdKey = "MicrosoftAppId"
 The key for Microsoft app Id. More...
const string MicrosoftAppPasswordKey = "MicrosoftAppPassword"
 The key for Microsoft app Password. More...

Protected Attributes

ILogger logger
readonly string TokenCacheKey

Static Protected Attributes

static readonly ConcurrentDictionary< string, OAuthResponsecache = new ConcurrentDictionary<string, OAuthResponse>()
static ConcurrentDictionary< string, DateTime > TrustedHostNames


string MicrosoftAppId [get, set]
string MicrosoftAppPassword [get, set]
virtual string OAuthEndpoint [get]
virtual string OAuthScope [get]

Detailed Description

Definition at line 24 of file MicrosoftAppCredentials.cs.

Constructor & Destructor Documentation

Microsoft.Bot.Connector.MicrosoftAppCredentials.MicrosoftAppCredentials ( string  appId = null,
string  password = null,
ILogger  logger = null 

Definition at line 66 of file MicrosoftAppCredentials.cs.

Microsoft.Bot.Connector.MicrosoftAppCredentials.MicrosoftAppCredentials ( IConfiguration  configuration,
ILogger  logger = null 

Definition at line 75 of file MicrosoftAppCredentials.cs.

Member Function Documentation

async Task<string> Microsoft.Bot.Connector.MicrosoftAppCredentials.GetTokenAsync ( bool  forceRefresh = false)

Definition at line 149 of file MicrosoftAppCredentials.cs.

static bool Microsoft.Bot.Connector.MicrosoftAppCredentials.IsTrustedServiceUrl ( string  serviceUrl)

Checks if the service url is for a trusted host or not.

serviceUrlThe service url
True if the host of the service url is trusted; False otherwise.

Definition at line 124 of file MicrosoftAppCredentials.cs.

override async Task Microsoft.Bot.Connector.MicrosoftAppCredentials.ProcessHttpRequestAsync ( HttpRequestMessage  request,
CancellationToken  cancellationToken 

Apply the credentials to the HTTP request.

requestThe HTTP request.
cancellationTokenCancellation token.

Definition at line 138 of file MicrosoftAppCredentials.cs.

static void Microsoft.Bot.Connector.MicrosoftAppCredentials.TrustServiceUrl ( string  serviceUrl,
DateTime  expirationTime = default(DateTime) 

Adds the host of service url to MicrosoftAppCredentials trusted hosts.

serviceUrlThe service url
expirationTimeThe expiration time after which this service url is not trusted anymore

If expiration time is not provided, the expiration time will DateTime.UtcNow.AddDays(1).

Definition at line 97 of file MicrosoftAppCredentials.cs.

Member Data Documentation

readonly ConcurrentDictionary<string, OAuthResponse> Microsoft.Bot.Connector.MicrosoftAppCredentials.cache = new ConcurrentDictionary<string, OAuthResponse>()

Definition at line 41 of file MicrosoftAppCredentials.cs.

ILogger Microsoft.Bot.Connector.MicrosoftAppCredentials.logger

Definition at line 44 of file MicrosoftAppCredentials.cs.

const string Microsoft.Bot.Connector.MicrosoftAppCredentials.MicrosoftAppIdKey = "MicrosoftAppId"

The key for Microsoft app Id.

Definition at line 29 of file MicrosoftAppCredentials.cs.

const string Microsoft.Bot.Connector.MicrosoftAppCredentials.MicrosoftAppPasswordKey = "MicrosoftAppPassword"

The key for Microsoft app Password.

Definition at line 34 of file MicrosoftAppCredentials.cs.

readonly string Microsoft.Bot.Connector.MicrosoftAppCredentials.TokenCacheKey

Definition at line 89 of file MicrosoftAppCredentials.cs.

ConcurrentDictionary<string, DateTime> Microsoft.Bot.Connector.MicrosoftAppCredentials.TrustedHostNames
Initial value:
= new ConcurrentDictionary<string, DateTime>(
new Dictionary<string, DateTime>() {
{ "", DateTime.MaxValue }

Definition at line 36 of file MicrosoftAppCredentials.cs.

Property Documentation

string Microsoft.Bot.Connector.MicrosoftAppCredentials.MicrosoftAppId

Definition at line 83 of file MicrosoftAppCredentials.cs.

string Microsoft.Bot.Connector.MicrosoftAppCredentials.MicrosoftAppPassword

Definition at line 84 of file MicrosoftAppCredentials.cs.

virtual string Microsoft.Bot.Connector.MicrosoftAppCredentials.OAuthEndpoint

Definition at line 86 of file MicrosoftAppCredentials.cs.

virtual string Microsoft.Bot.Connector.MicrosoftAppCredentials.OAuthScope

Definition at line 87 of file MicrosoftAppCredentials.cs.

The documentation for this class was generated from the following file: