csharp-teams-sample-graph
csharp-teams-sample-graph copied to clipboard
Microsoft.Graph : One or more errors occurred. (Message: This request is forbidden. Inner error )
Hi Team,
I am getting "This request is forbidden." error when I am trying to Post/Get Graph API. Providing sample code which i am using:
var tenantId = "MY-TENANTID"; var clientId = "MY_CLIENT_ID"; var clientSecret = "MY_CLIENT_SECRET";
//create an authProvider
IConfidentialClientApplication confidentialClientApplication = ConfidentialClientApplicationBuilder
.Create(clientId)
.WithTenantId(tenantId)
.WithClientSecret(clientSecret)
.Build();
ClientCredentialProvider authProvider = new ClientCredentialProvider(confidentialClientApplication);
var graphClient = new GraphServiceClient(authProvider);
var t= graphClient.Teams["TEAM_ID"].Channels["CHANNEL_ID"] .Request() .GetAsync().Result;
Here I am pasting screen shot of : graphClient object

Also pasting exception detail:

Please let me know if Iam doing something wrong. My simple requirement is send to message to channel.
Closing this as we are closing this repository and will no longer maintain it. The Teams code snippets in this sample are replicated in the ASP.NET Core Graph Snippets sample. We apologize for any inconvenience.