Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
135 views
in Technique[技术] by (71.8m points)

App only C# code, does not work like the Graph explorer

In graph explorer:

https://graph.microsoft.com/v1.0/teams/aebabbef-180f-49f6-92c9-be4201be286d/channels/19:[email protected]/messages 

works fine I get a json with data.

The code snippets shows:

var messages = await graphClient.Teams["aebabbef-180f-49f6-92c9-be4201be286d"].Channels["19:[email protected]"].Messages
.Request()
.GetAsync();

So I use it as is in a console application With app only permission that has all the graph permissions but I get the error:

Code: UnknownError
Inner error:
        AdditionalData:
        date: 2021-01-24T20:03:02
        request-id: 9c294c0c-328a-4ca4-bcd0-1cbb3999dfd7
        client-request-id: 9c294c0c-328a-4ca4-bcd0-1cbb3999dfd7
ClientRequestId: 9c294c0c-328a-4ca4-bcd0-1cbb3999dfd7

anyone know what the error can be?

Thanks

question from:https://stackoverflow.com/questions/65875476/app-only-c-sharp-code-does-not-work-like-the-graph-explorer

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This is because the List Channel Messages endpoint doesn't support App only permissions as shown below. Please check the documentation here. It works on the Graph Explorer because it gets the user token there.

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...