Language

TeamsAgentExtension.GetAppGraphClientForConnection(String, String) Method

Definition

Creates a new instance of the GraphServiceClient for accessing Microsoft Graph APIs using an app-only (application) token from the named token connection.

public Microsoft.Graph.GraphServiceClient GetAppGraphClientForConnection(string connectionName, string graphBaseUrl = "https://graph.microsoft.com/v1.0");
member this.GetAppGraphClientForConnection : string * string -> Microsoft.Graph.GraphServiceClient
Public Function GetAppGraphClientForConnection (connectionName As String, Optional graphBaseUrl As String = "https://graph.microsoft.com/v1.0") As GraphServiceClient

Parameters

connectionName
String

The name of the token connection whose credentials are used to acquire the app-only token. Cannot be null or empty.

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

This overload uses the credentials of the token connection identified by connectionName rather than resolving the connection from the current turn, so it does not require a turn context. 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 named token connection is required.

Applies to