Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
132 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 Reply

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...