How to send a message to MS teams from standalone application

Supriya Saraogi 1 Reputation point

I'm trying to send message to MS teams channel from my application. The documentation sending chat message to msteams channel is all over the place. It's not helpful for developers. I understand that to send message to MS teams first I'll have to configure an auth provider.

Things tried so far:

  1. created an auth provider. In my case I used client auth provider
 // Create an auth provider
      final ClientSecretCredential clientSecretCredential = new ClientSecretCredentialBuilder()

      List<String> scopes = Arrays.asList(MSTEAMS_SCOPE);

      final TokenCredentialAuthProvider tokenCredentialAuthProvider =
          new TokenCredentialAuthProvider(scopes, clientSecretCredential);
  1. Created graph client object
           final GraphServiceClient<Request> graphClient =
  2. Trying to send chat message to Ms Teams

When I'm trying to send the message the code gets stuck at this is part of - package; in line

            final CompletableFuture<String> future = authProvider.getAuthorizationTokenAsync(originalRequest.url().url());

there is no error thrown. Can someone help me understand what am I missing.

PS: I have added the delegated permissions and I'm using my work account to send the request. Also already referred to following documentation

Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
7,627 questions
Microsoft Graph Groups API
Microsoft Graph Groups API
A Microsoft API that creates and manages different types of groups and group functionality.
228 questions
Microsoft Graph SDK
Microsoft Graph SDK
A Microsoft software developer kit designed to simplify building high-quality, efficient, and resilient applications that access Microsoft Graph.
991 questions
Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
2,367 questions
{count} votes