Graph API, getting Team/Channel members from private channel - microsoft-graph-api

I need to get the list of members from a SPA that is hosted as a tab in a private channel in Microsoft Teams. I know how to query it from this page. So the request is something like this:
GET https://graph.microsoft.com/beta/teams/<group_id>/channels/<channel_id>/members
The problem is from the SPA I couldn't get the groupId because in a private channel the context provided by Microsoft Teams SDK is undefined. I know that this is done to provide privacy for the channel. But, are there any other queries that I could use to get the members, or is there any other way to get groupId from a private channel?

Copying Answer from the comments
To get the list of members from a private channel, you can call GET graph.microsoft.com/v1.0/me/joinedteams and get the corresponding Team ID/Group ID and call GET graph.microsoft.com/v1.0/Teams{groupID}/channels/{PrivateChannelID}/members

Related

Is there a way to limit private channels requests to those the user has access to?

I'm working with the Graph to retrieve users Teams and Channels, but have come across an issue with making calls to the /v1.0/teams/[team-id]/channels endpoint. It lists out all channels in the team, including private channels the user doesn't have access to. We have to make an extra call to the specific channel to see if the user has access, which in our case means we have to batch potentially hundreds of calls and that has the potential to block rendering of our add-in.
In the following example, this user has access to a team called 'Test Team with public sharing' and has access to the 'General' and 'Canal partage' channels. There's a private channel 'Private channel' the user isn't a part of, and a shared channel that we were using for testing.
You can see the private channel is in the response from /[team-id]/channels:
But the channel doesn't appear in the Teams client:
Is there a way to filter out channels the user doesn't have access to? Is this something I can request? At best it has the potential to significantly impact performance of our add-in, at worst it could open users up to security issues. Consider a private channel created to discuss the future of an employee, or a group of dissatisfied employees creates a 'Our boss is mean' private channel and excludes their boss. The channel won't show in the Teams client, but has the potential to show in any other add-in or application that uses the Graph API.
In our add-in we're using this call to exclude shared channels for the moment:
/channels?& $select=id,displayName,membershipType,webUrl$filter=membershipType eq 'private' or membershipType eq 'standard'
Ideally the Graph would exclude channels the user doesn't have access to, next best thing would be to have a property on the channel to identify the user doesn't have permissions. Maybe a permissions mask or something like that.

Microsoft Graph API Bookings - Public URL for booking service

Using the Microsoft Graph Beta REST API for Customer Bookings I would like to retrieve the public link for a specific booking service page, which is available through the MS Bookings app here:
Booking service sharable URL
It looks like: https://outlook.office365.com/owa/calendar/[bookingBusinessEmail]/bookings/s/LdQCYS7WqEa7upCnyiybFg2
However, it doesn't seem to be in the response body for bookingService or any other resource: https://learn.microsoft.com/en-us/graph/api/resources/bookingservice?view=graph-rest-beta
Is there a way via MS Graphs to get this link?
Thanks
Looking through the documentation shared and the Bookings resources, it looks like there isn't yet a way to retrieve the public link using MS Graph.

Is there a way to create a private channel's SharePoint site?

We currently have an issue when creating private channels on a team which was created using the "/teams" Graph API endpoint.
When adding a private channel from the Graph API, the SharePoint site associated to the channel is not provisioned. User needs to visit the "Files" tab in the MSTeams client for the site to be created.
We noticed that this is not the case when initially creating the Team from the MSTeam client or from the "/groups/{id}/team" endpoint (which is marked as being soon deprecated). Using either of those two methods to create the team, SharePoint sites are automatically created when adding a private channel.
We were wondering if this was the expected behaviour or a bug. It is an issue for us as we have no way to automate the creation of the private channel's site and thus we cannot copy files into the site as long as a user did not visit the "Files" tab.
#odrouin - This is not expected behavior. We have bug created for this issue. Thanks for reaching out.
I think I've found a workaround for this issue. It seems like if you first make a call to the filesFolder endpoint on the primaryChannel of the team (the General channel), then the site will be provisioned for a private channel created afterward.

Returning employeeId of a user through MS Graph API

I've been trying to return the employeeId of a user through the Microsoft Graph API but so far haven't had much luck.
I'm assuming this is probably because it doesn't exist in the metadata for the user in the Graph API so makes sense.
However, the property is populated in Azure AD. If I use the AZ command prompt to query the user I can see the property. Likewise, if I query the old Active Directory Graph API endpoint I can even see it there.
For example, querying
https://graph.windows.net/{tennant}/users/{upn}?api-version=1.6 directly I receive the employeeId as part of the response (using the ActiveDirectoryClient however seems to ignore this property and doesn't store it anywhere).
Is there any reason for this? Wouldn't it make sense to have it returned as an additional property? I've also looked into extensions, but as it's not an extension isn't returned there.
Any help would be appreciated. I can get the information I need by querying the old endpoint directly, but this seems like a complete backwards step and involves multiple queries to get the information I need - including having to use multiple end points (one of which I assume will be deprecated and removed soon).
EmployeeId is currently a beta feature and is only available in the beta endpoint of the Graph API.
So if you want to access the beta endpoint you just have to change the version to beta in your url. For example:
https://graph.microsoft.com/beta/me/
https://graph.microsoft.com/beta/users/{id|upn}/
https://graph.windows.net/{tennant}/users/{id|upn}?api-version=beta
For more information about the user-object in the beta endpoint see: https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/resources/user

How to fetch Youtube public channel stats without authentication

I am trying to fetch metrics like views, likes, dislikes for videos in some popular public Youtube channels and also subscription information of the Channelsa on a daily basis. Also, country wise stats and gender wise stats for the channels required. But, Youtube Reporting API always prompts authentication. Is there any way to fetch those metrics for public Youtube channels without user authentication?(https://www.googleapis.com/youtube/analytics/v1/reports - need to use this API). Your suggestions will be very helpful.
For some of read-only requests you can just use access token without need to authorize. Check the documentation. Each request's documentation tells if authorization is needed.
The API you linked to is part of the "YouTube Analytics and Reporting APIs", which is split up in these very two pieces - analytics and reporting. I don't see why you need to use this exact API, but I can tell you that you won't succeed with it. This API is intended for channel owners and network owners to get information about their own channels. You absolutely have to authenticate via OAuth in order to use it, there is no way around this.
In order to get video and channel metrics, you can consult the YouTube Data API. Here, an API key from the Google Cloud Console will let you fetch any public data without further authentication. But it will not provide you with data records in specific periods of time, it always returns the current values of the requested properties.
In other words: what you are asking is, as far as I know, impossible to achieve with any official YouTube API.
A workaround for your problem would be to fetch the desired properties via the Data API on a, say, daily basis and compare their values to the previous day's values and calculate the delta.

Resources