r/GraphAPI • • Jul 22 '24

Exporting Bitlocker Keys via Graph

1 Upvotes

Has anyone gotten this to work? I'm trying to use the following code just to start with

$TenantId           = "<< Tenant ID >>"
$ClientId           = "<< Client App ID >>"
$ClientSecret       = "<< Client Secret >>"

$SecureClientSecret = ConvertTo-SecureString -String $ClientSecret -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential ($ClientId, $SecureClientSecret)

Connect-MgGraph -TenantId $TenantId -ClientSecretCredential $Credential -NoWelcome

$BitLockerKeys = Get-MgInformationProtectionBitlockerRecoveryKey -All

However as soon as it runs Get-MgInformationProtectionBitlockerRecoveryKey I get the following error

Get-MgInformationProtectionBitlockerRecoveryKey_List: Failed to authorize, token doesn't have the required permissions.

Status: 403 (Forbidden)
ErrorCode: authorization_error
Date: 2024-07-22T18:52:05

Headers:
Vary                          : Accept-Encoding
Strict-Transport-Security     : max-age=31536000
request-id                    : 
client-request-id             : 
x-ms-ags-diagnostic           : {"ServerInfo":{"DataCenter":"North Central US","Slice":"E","Ring":"4","ScaleUnit":"000","RoleInstance":""}}
Date                          : Mon, 22 Jul 2024 18:52:05 GMT

Looking online everyone says to use the -scope flag while connecting and looking at Microsoft's page it shows that there should be Application permissions however when you go into the app to grant this permission only delegated permissions exists. https://learn.microsoft.com/en-us/graph/api/bitlockerrecoverykey-get?view=graph-rest-1.0&tabs=http#permissions

So I have my application setup with the following API Permission all Admin Consented

Delegated --> Microsoft.Graph.BitlockerKey.Read.All

Delegated --> Microsoft.Graph.BitlockerKey.ReadBasic.All

Delegated --> Microsoft.Graph.User.Read

I've also per the documentation above granted this application Security Reader and Global Reader role in Entra. I've even tried adding it to Global Admin just to see if it would work and it doesn't.

Looking for any help here to try to get this working. After this Crowdstrike issues this past week we found some machine that we couldn't find Bitlocker keys for and would like to do a Audit of our Bitlocker entries.


r/GraphAPI • • Jul 03 '24

Add planner to a Teams channel

1 Upvotes

Hi,

I want to use C# to add a planner to a tab in Teams. I'm following https://learn.microsoft.com/en-us/graph/api/channel-post-tabs?view=graph-rest-1.0&tabs=csharp but I'm lost in the ContentUrl and WebsiteUrl part.

I have a {team-id} a {channel-id} and a {planner-id} but I'm having throuble to connect this all together.

It did work a couple of weeks ago before the new planner in Teams. Now I get all my Tasks instead of the one planner I created for this Team.

This was the code before Microsoft introduced the new planner in Teams instead of the Tasks

ContentUrl =
    "https://tasks.teams.microsoft.com/teamsui/{tid}/Home/PlannerFrame?page=7&auth_pvr=OrgId&auth_upn={userPrincipalName}&groupId={groupId}&planId=" +
    plannerId +
    "&channelId={channelId}&entityId={entityId}&tid={tid}&userObjectId={userObjectId}&subEntityId={subEntityId}&sessionId={sessionId}&theme={theme}&mkt={locale}&ringId={ringId}&PlannerRouteHint={tid}&tabVersion=20200228.1_s",
WebsiteUrl = "https://tasks.office.com/<TENANTID>/Home/PlanViews/" +
             plannerId + "?Type=PlanLink&Channel=TeamsTab",

If I go to settings in teams and select the existing planner in this Teams it does work. So everything is there, I only don't know how to couple them together


r/GraphAPI • • May 24 '24

Entra ID Connect Health Alerts

1 Upvotes

Anyone know of a way to pull Entra ID connect sync health alerts? The closest query I can see is Get /organization. This includes a last sync time.


r/GraphAPI • • May 15 '24

Get Sign-In's with multiple failed MFA attempts

1 Upvotes

I want to use an Azure automation to block accounts that have multiple denied MFA attempts automatically. Number matching should prevent MFA fatigue attacks, but I would also like to block the account so I can change the user's password and revoke all sessions.

This is what the sign in looks like for testing:

How do I go about this?


r/GraphAPI • • May 12 '24

What platform are using graph API with?

1 Upvotes

Besides PoweShell


r/GraphAPI • • May 12 '24

Microsoft Graph question - Single day all-day event spans two days in outlook calendar app?

1 Upvotes

When i add the all day event via Microsoft graph api it extends to the next date.

But after i click on the event it displays the event as all-day event


r/GraphAPI • • May 01 '24

How would I do this (can it be done this way?)

1 Upvotes

I am 100% new to graph, and have hardly ever used PowerShell, but I have been tasked with getting a list of all the apps for enterprise from azure AD (or entra, whatever the hell MS is calling now), from this list, I need to parse out the created date, and who created it. is there a simple (relatively) script to do this, or will this turn into a larger project?

I was able to get a list using graph explorer, so if worse comes to worse I could probably make a script to search that info from a text file, and compile it into a csv using maybe python or JavaScript? (I'm not a programmer by trade, I took some programming classes 7 years ago, but have been on the hardware side after that, until now. so my skills are small, and rusty.)

any help is greatly appreciated. Also if this is the wrong sub, please kindly point me in the direction of the correct one.


r/GraphAPI • • Apr 30 '24

Graph API - Deleting not working with username/password auth

1 Upvotes

Would love some help from any experts on this. I'm attempting to build a simple service that pulls emails from an Office 365 email box using the Microsoft Graph API. The service finds all new email, processes them using internal business logic, then deletes them from the box. Very standard service.

I've tried using both Application and Delegated authority and can't get it working either way. I can read the email, but deleting or moving it fails.

Dim graphClient As GraphServiceClient = Nothing
Dim scopes = {"Mail.ReadWrite"}
Dim options = New UsernamePasswordCredentialOptions With {.AuthorityHost = AzureAuthorityHosts.AzurePublicCloud}
Dim userNamePasswordCredential = New UsernamePasswordCredential(username:=username, password:=password, tenantId:=tenantId, clientId:=applicationId, options:=options)
graphClient = New GraphServiceClient(userNamePasswordCredential, scopes)

... Pull Emails... Now delete them:

Dim userReqHelper = graphClient.Me.Messages(messageId)
Await userReqHelper.DeleteAsync()

This throws an exception of "Content type text/html does not have a factory registered to be parsed"

I've tried deleting it with userReqHelper = graphClient.Users(userId).Messages(messageId).DeleteAsync() and userReqHelper = graphClient.Me.MailFolders(sourceFolder).Messages(messageId).DeleteAsync() with the same problem. I tried switching to using application client/secret authentication, but apparently delete doesn't support that. I tried interactive and it doesn't seem to work either, some kind of problem with the scope.

Application is registered with the tenant in Entra as an enterprise application with permissions and grants:

I also enabled public client flows since some research showed that might help.

Any suggestions appreciated!


r/GraphAPI • • Apr 02 '24

To apply SiteDesign to a site

1 Upvotes

Is there a way in graph api to apply site design to a SharePoint site?


r/GraphAPI • • Apr 02 '24

To apply SiteDesign to a site

1 Upvotes

Is there a way in graph api to apply site design to a SharePoint site?


r/GraphAPI • • Mar 26 '24

Getting errors trying to bulk update user contact information in Office 365

1 Upvotes

I am getting the following error when try to bulk update users contact information using PowerShell and a CSV file.

Update-MgUser : Invalid value specified for property 
'officeLocation' of resource 'User'.
Status: 400 (BadRequest)
ErrorCode: Request_BadRequest
Date: 2024-03-26T17:05:02
Headers:
Transfer-Encoding             : chunked
Vary                          : Accept-Encoding
Strict-Transport-Security     : max-age=31536000
request-id                    : e564c626-6a9d-4229-9762-c1c1ff50b3fd
client-request-id             : bcd83082-18c4-40df-a1cf-26fd77908be9
x-ms-ags-diagnostic           : {"ServerInfo":{"DataCenter":"Canada Central","Slice":"E","Ring":"5","ScaleUnit":"001","RoleInstance":"YT1PEPF00001AC2"}}
x-ms-resource-unit            : 1
Cache-Control                 : no-cache
Date                          : Tue, 26 Mar 2024 17:05:01 GMT
At C:\azure\AzureADInport3.ps1:80 char:13

Here is the script that I am using

# Connect to Microsoft Graph
Connect-MgGraph -Scopes User.ReadWrite.All

# Read the CSV file
$users = Import-Csv -Path "C:\Azure\AllAzureADUsers.csv"

# Go through each user in the CSV and update the properties foreach ($user in $users) {
$Userprincipalname = $user.Userprincipalname
$jobTitle = $user.JobTitle
$country = $user.Country
$CompanyName = $user.CompanyName
$StreetAddress = $user.StreetAddress
$City = $user.City
$Postalcode = $user.Postalcode
$State = $user.State
$Country = $user.Country
$MobilePhone = $user.MobilePhone
$BusinessPhones = $user.BusinessPhones

# Check if the user exists
$existingUser = Get-MgUser -UserID $Userprincipalname -ErrorAction SilentlyContinue

if ($existingUser) {
    # Check if the existing properties match the new values
    $updateNeeded = $false

    if ($existingUser.Userprincipalname -ne $Userprincipalname) {
        $existingUser.Userprincipalname = $Userprincipalname
        $updateNeeded = $true
    }

    if ($existingUser.JobTitle -ne $jobTitle) {
        $existingUser.JobTitle = $jobTitle
        $updateNeeded = $true
    }

    if ($existingUser.CompanyName -ne $CompanyName) {
        $existingUser.CompanyName = $CompanyName
        $updateNeeded = $true
    }

    if ($existingUser.StreetAddress -ne $StreetAddress) {
        $existingUser.StreetAddress = $StreetAddress
        $updateNeeded = $true
    }

    if ($existingUser.City -ne $City) {
        $existingUser.City = $City
        $updateNeeded = $true
    }

    if ($existingUser.Postalcode -ne $Postalcode) {
        $existingUser.Postalcode = $Postalcode
        $updateNeeded = $true
    }

    if ($existingUser.State -ne $State) {
        $existingUser.State = $State
        $updateNeeded = $true
    }

    if ($existingUser.Country -ne $country) {
        $existingUser.Country = $country
        $updateNeeded = $true
    }

    if ($existingUser.MobilePhone -ne $MobilePhone) {
        $existingUser.MobilePhone = $MobilePhone
        $updateNeeded = $true
    }

    if ($existingUser.BusinessPhones -ne $BusinessPhones) {
        $existingUser.BusinessPhones = $BusinessPhones
        $updateNeeded = $true
    }

    if ($updateNeeded) {
        # Update the user properties
        Update-MgUser -UserID $userPrincipalName -JobTitle $jobTitle -CompanyName $CompanyName -OfficeLocation $OfficeLocation -StreetAddress $StreetAddress -City $City -Postalcode $Postalcode -State $State -Country $country
        Write-Host "User '$Userprincipalname' updated successfully." -ForegroundColor Green
    }
    else {
        Write-Host "User '$Userprincipalname' properties are up to date." -ForegroundColor Cyan
    }
}
else {
    # User not found
    Write-Host "User '$Userprincipalname' not found." -ForegroundColor Red
}

Any ideas?


r/GraphAPI • • Mar 20 '24

Microsoft Plans to Retire Application Impersonation Role in Exchange Online!

Thumbnail
self.admindroid
1 Upvotes

r/GraphAPI • • Mar 14 '24

Call out members of security groups including nested ones

1 Upvotes

Hi,

Is there an http syntax dedicated for members expand from group and each nested groups? Also how to avoid getting group itself in output. I work in power query, so I can't use advanced scripting.

Cheers and thanks in advance


r/GraphAPI • • Mar 09 '24

Add a group with read/write access to a specific folder within a users OneDrive ?

1 Upvotes

tl;dr - I have got as far as scripting everything from getting the user, their one drive id, the folder id and then the permissions on the folder so that it checks if the group exists or not. This is the final hurdle. I am trying to ADD a group ( by group ID ) with read/write permissions to this folder. I don't want to send a sharing link. I just want to straight up ADD the group with access to this folder.

I currently get a "400 - Bad Request" response.

The Graph Explorer doesn't seem to show addining of OneDrive permissions and the documentation around it seems to only focus on sending invite links.

I am making a POST call to https://graph.microsoft.com/v1.0/drives/[$OneDrive_ID]/items/[$Folder_ID]/permissions

and in the request body I am passing JSON:

{
  "roles": ["write"],
  "grantedToIdentities": [
    {
      "user": {},
      "group": {
        "id": "12345"
      }
    }
  ]
}

I have tried many variations of the POST URL

Any help appreciated, thank you


r/GraphAPI • • Feb 13 '24

Defender Threat Email Submission API

1 Upvotes

r/GraphAPI • • Jan 31 '24

Graph API AssignedLabel filtering

1 Upvotes

Hello everyone!

I'm making a graph API call the following way:https://graph.microsoft.com/beta/users/{user_ID}/ownedObjects/microsoft.graph.group$select=id,displayname,createdDateTime,assignedLabels&$count=true&$filter=assignedLabels/any(label : label/displayName eq 'TEST')

In essence I'm trying to fetch all the groups that contain the label "Test"

What I would expect to get back as a reply is this:

"@odata.context": "https://graph.microsoft.com/beta/$metadata#groups(id,displayName,createdDateTime,assignedLabels)",

"value": [

{

"id": "[GUID]",

"displayName": "TEST",

"createdDateTime": "2023-02-04T15:24:05Z",

"assignedLabels": [

{

"labelId": "[GUID]",

"displayName": "TEST"

}

]

}

However I'm getting the following reply back:

{

"error": {

"code": "Request_UnsupportedQuery",

"message": "Unsupported query on property 'AssignedLabel'.",

"innerError": {

"date": "2024-01-31T15:31:13",

"request-id": "8f3de165-3c0b-4ff2-84ac-95f0ab042227",

"client-request-id": "8f3de165-3c0b-4ff2-84ac-95f0ab042227"

}

}

}

Any idea why this filter operation is invalid?Thank you!


r/GraphAPI • • Jan 21 '24

Best Practices for Integrating Microsoft Calendar API into Salon Chatbot – Seeking Advice!

1 Upvotes

Hello!

I'm currently developing a chatbot aimed at streamlining salon appointment bookings, and I'm diving into the world of Microsoft Calendar API for integration. The objective is to let the chatbot schedule appointments on behalf of both the salon and its employees.

I'm facing two major challenges and could use your expertise:

  1. Managing Salon Availability:

  • How do you recommend letting salons manage their availability inside microsoft calendar so that the getSchedule API can see when the salon is available.

  • (a little background) If I would use the working hours feature, then i won't be able to have the staff of the salon have a shared account, since the working hours only count for the entire account (I think).

  • Another option is to let the salon staff create recurring events with "status"/"showAs": "free" (when creating an event inside outlook calendar, in the top part you can change busy to free when creating an event). This option truly is a bad idea organization wise, but gets the job done so thats why i mention it.

  1. Structuring Multiple Calendars:

  • What's the best way to structure different calendars for salon employees? How could permissions for accessing each other's calendars be managed? Can I share agendas through API's or should I let staff have a shared account?

I'm still learning the ropes of Microsoft APIs and feeling a bit stuck in the calendar/booking part of my project. If you think Microsoft Calendar might not be the best fit, I'm open to alternative suggestions that align with my goals.

Your insights, recommendations, and tips would be immensely valuable in steering this project in the right direction. Thanks a bunch for your help!


r/GraphAPI • • Jan 16 '24

Fetching list of ‘Search terms’ on SharePoint’s search box using graph api.

1 Upvotes

I am looking to create a power bi report to analyze search terms users are putting into the search box in SharePoint. Can this be accomplished using graph api ?


r/GraphAPI • • Jan 06 '24

web based program for user to reset other user's email password

1 Upvotes

Is it possible to reset user passwords through web based program and graph? Or, is there a better way? I have a personal account that I use to maintain multiple domain names with a mix of a few hundred exchange/365 mailboxes. I would like to assign a different admin to each domain name so that the admin can (only) reset passwords for email accounts under their domain. Is this possible?


r/GraphAPI • • Jan 05 '24

Getting invalid_grant everytime I ask for a new access token

1 Upvotes

Hello everybody,

need your help. I'm trying to ask a new access token to the Graph API but everytime the server reply with "invalid_grant" as you can see in the picture.

Can you help me?

Thank you!


r/GraphAPI • • Dec 07 '23

Post in facebook with APIGRAPH

1 Upvotes

Hii, I'm trying to make a post on Facebook, using the Graph API, with country restriction. but I have an error with the location_types field, I am attaching an image of my query in postman. (https://i.stack.imgur.com/EPZmb.png)

Does anyone know what causes this error?


r/GraphAPI • • Nov 18 '23

User API $top Limitation When Using &expand Question

1 Upvotes

Using pl/sql (12c) to pull down all users in Azure, flatten out the json and table the data.

If I use $select in combination with $top=999 I'm returned an array with 999 objects (key/pairs).

example: https://graph.microsoft.com/v1.0/users?$select=employeeId,onPremisesSamAccountName&$top=999 [this returns 999]

However, if after the $select, I add $expand=manager($levels=1;$select=id), regardless of the $top value, I'm only returned 200.

example: https://graph.microsoft.com/v1.0/users?$select=employeeId,onPremisesSamAccountName&$expand=manager($levels=1;$select=id)&$top=999 [this only returns 200]

Is this a known limitation due to the query parameters of 'select' and 'expand' in the same request? When the number of users in Azure is ~44k, having 200+ get iterations to pull all the data seems excessive.

Any advice would be helpful. I'm open to ideas/criticism.

Regards.


r/GraphAPI • • Oct 10 '23

Question, easy guide to change the "employeeLeaveDateTime" attribute on a user trough Graph?

1 Upvotes

How do I accomplish this? I'm not experienced in Graph so a simple guide would be really helpfull!


r/GraphAPI • • Oct 06 '23

Microsoft Graph Calendar API all-day events timezone issue

1 Upvotes

I'm getting this issue while fetching calendar events that all-day events are not obeying the prefer outlook.timezone. They are being returned as dates in the calendar user's timezone.

I need a solution to this as I save these events in my application and need to know the time zone before saving them.

I reported the question on Microsoft QA with additional details please have a look at that as well:

https://learn.microsoft.com/en-us/answers/questions/1382503/all-day-events-are-not-obeying-prefer-outlook-time