TeamsAgentExtension.GetAppGraphClient(ITurnContext, String) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Creates a new instance of the GraphServiceClient for accessing Microsoft Graph APIs using an app-only (application) token from the agent's configured token connection.
public Microsoft.Graph.GraphServiceClient GetAppGraphClient(Microsoft.Agents.Builder.ITurnContext turnContext, string graphBaseUrl = "https://graph.microsoft.com/v1.0");
member this.GetAppGraphClient : Microsoft.Agents.Builder.ITurnContext * string -> Microsoft.Graph.GraphServiceClient
Public Function GetAppGraphClient (turnContext As ITurnContext, Optional graphBaseUrl As String = "https://graph.microsoft.com/v1.0") As GraphServiceClient
Parameters
- turnContext
- ITurnContext
The turn context. Its Identity and Activity are used to resolve the connection. Cannot be null.
- graphBaseUrl
- String
The base URL for the Microsoft Graph API. Defaults to "https://graph.microsoft.com/v1.0".
Returns
A GraphServiceClient instance authenticated with an app-only token.
Remarks
Unlike GetGraphClient(ITurnContext, String, String), which acquires a token for the signed-in user, this method uses the credentials of the token connection resolved for the current turn (via GetTokenProvider(ClaimsIdentity, IActivity)). The returned client is authenticated with application permissions, so the caller must specify the target resource in the request path (for example client.Users["{userId}"]...). No additional configuration beyond the existing token connection is required.