Hi anonymous user
Combined with your context, I suggest you use ROPC flow to get access token and update group. Refer to the complete code:
using Azure.Identity;
using Microsoft.Graph;
var scopes = new[] { "Group.ReadWrite.All" };
// Multi-tenant apps can use "common",
// single-tenant apps must use the tenant ID from the Azure portal
var tenantId = "tenant id";
// Value from app registration
var clientId = "client id";
// using Azure.Identity;
var options = new TokenCredentialOptions
{
AuthorityHost = AzureAuthorityHosts.AzurePublicCloud
};
var userName = "user name";
var password = "password";
// https://learn.microsoft.com/dotnet/api/azure.identity.usernamepasswordcredential
var userNamePasswordCredential = new UsernamePasswordCredential(
userName, password, tenantId, clientId, options);
var graphClient = new GraphServiceClient(userNamePasswordCredential, scopes);
var group = new Group
{
AutoSubscribeNewMembers = true
};
await graphClient.Groups["group id"]
.Request()
.UpdateAsync(group);
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.