Microsoft Teams (beta) API: Looks like you may not

2020-06-20 07:51发布

问题:

I used the Graph Explorer to test against my Office 365 profile. Everything works fine accept the Microsoft Teams (beta) API. If I use GET https://graph.microsoft.com/beta/me/joinedTeams I get

Status Code 401 - Looks like you may not have the permissions for this call. Please modify your permissions.

{
    "error": {
        "code": "",
        "message": "Authorization has been denied for this request.",
        "innerError": {
            "request-id": "a1733d8a-5adb-45ad-a0ad-463595d71a89",
            "date": "2017-06-09T14:33:11"
        }
    }
}

There seems no option for give permission for Microsoft Teams. Has anyone figured that out, yet?

回答1:

The documentation page for listing your joined teams is at https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/user_list_joinedteams. It looks like this call requires the User.Read.All or User.ReadWrite.All permissions. To change your permissions in the Graph explorer, you can click Modify Permissions

Then find and enable either permission:

However, these scopes require tenant administrators to let the Graph Explorer use admin only scopes. You can either just login as an administrator to just test with that account, or you can let any user in your organization access admin scopes through the explorer by clicking the link that says grant access to your entire organization.

Also, I'm glad you found the Microsoft Teams samples. We just added these last week and it's great to see developers are trying them out! Thanks for your feedback on the permissions process for the Teams in explorer, I'll pass that along to all the engineers on the project.



回答2:

I've created a command line tool that lets you bulk create new Microsoft Team channels using the Graph APIs outlined above. It includes instructions on how to register your application for use with your Teams environment - and provide administrative consent so that non-admins can use it.

One of the API calls is to "joinedTeams", which lists the Teams you're currently a member of. Take a look in "SelectJoinedTeam" function in the ChannelSurfCli/Utils/Channels.cs class.

https://github.com/tamhinsf/ChannelSurf