I am trying to create an integration with Yammer (Viva Engage) to post messages in communities (also accepting ideas if there is a better way to accomplish my goal.). I created a Yammer client application to impersonate a user to post messages in the communities that user is in. I am trying to authenticate with the Yammer API to generate an Azure Active Directory (AAD) token using the MSAL library in .NET Framework 4.8 to call these API endpoints, but it fails (see below).
I want to call the get current user to get the current user's id, get communities for user to get the communities that user is in, and post messages to post messages to the communities that user is in.
I am following the authentication steps recommended in Yammer's documentation. However, the documentation is vague on how to use the client id and client secret to authenticate with Yammer's API using the MSAL library.
I wrote the following code to try to generate the Azure Active Directory (AAD).
string clientId = "";
string clientSecret = "";
IConfidentialClientApplication confidentialClientApplication = ConfidentialClientApplicationBuilder
.Create(clientId)
.WithClientSecret(clientSecret)
.Build();
AuthenticationResult authResult = await confidentialClientApplication
.AcquireTokenForClient(scopes: new[] { "https://api.yammer.com/.default" })
.ExecuteAsync();
var token = authResult.AccessToken;
I get an error when I run this code, saying,
AADSTS700016: Application with identifier '[Client Secret]' was not found in the directory 'Microsoft'. This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You may have sent your authentication request to the wrong tenant.
Any ideas on what scopes I need to use or how I should generate an Azure Active Directory (AAD) token using the MSAL library in .NET Framework 4.8 to authenticate with the Yammer API?