Language

BotTokenProvider.GetAppTokenAsync(String, String, CancellationToken) Method

Definition

Acquire an app-only token for the given scope.

public System.Threading.Tasks.Task<string?> GetAppTokenAsync(string scope, string? tenantId = default, System.Threading.CancellationToken cancellationToken = default);
member this.GetAppTokenAsync : string * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<string>
Public Function GetAppTokenAsync (scope As String, Optional tenantId As String = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of String)

Parameters

scope
String

The resource scope to request, e.g. https://graph.microsoft.com/.default.

tenantId
String

Tenant to acquire against, overriding the one the named MSAL options configure. Pass the tenant the work is being done in, which for a multi-tenant app is not the app's own. null leaves the configured authority alone, which is what a single-tenant app wants.

cancellationToken
CancellationToken

A token to cancel the acquisition.

Returns

The bearer token without its scheme prefix.

Applies to