r/GraphAPI • • Jul 01 '25

Is it ok for an internal enterprise app to use ROPC authorization?

1 Upvotes

I'm writing something to auto-remind employees on a scheduled basis via a teams message sent from a 'donotreply' account. All went well in Postman when I was testing the endpoints I'll need, but when I started writing the script, I realized I had been using delegated permissions in Postman after logging in as the donotreply account. My application will not be able to complete the oauth handshake to work this way (for one, it's hosted on our intranet and will not have a public-facing redirect uri, and it will be executed on a scheduled basis without user interaction to authorize/receive the auth token).

I've setup similar internal apps with Application permissions but there doesn't seem to be an Application permission for sending Teams chat messages.

So, the solution that makes the most sense to me is to use ROPC authentication, passing my donotreply account's credentials along with the app's secret to get the auth token. I just tried it, and it works great.

My only concern is that Microsoft speaks of ROPC authentication as like a thing of the past, with a section of how to 'migrate away' from it... https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth-ropc Their solution for web applications with back-end authentication is to use application permissions, which does not help for my particular use-case...

So is ROPC authentication the best way to do this or am I missing another option? Unfortunately I have no access to manage app permissions myself so if you have any suggestions, it would be great to have something to point my NetOps coworkers at to get this setup.

Thanks!


r/GraphAPI • • Jun 02 '25

How long for email messages to be available to Graph API?

1 Upvotes

Does anyone know on average how long it takes for emails delivered to a users mailbox to show up as readable via the Graph API?

I have a vendor saying it’s instant but I cannot find any details on the accuracy of this claim. I have asked for metrics from the vendor as well.

Anyone have any insight?


r/GraphAPI • • May 29 '25

MSGraph GET API filtering

1 Upvotes

Hello, just want to ask if there's any way to filter the highlighted 'fields' from the GET API call.
I'm using this URI '.../items?$expand=fields'


r/GraphAPI • • May 27 '25

How to create a reply draft that belongs to an email thread

1 Upvotes

Hello, I want to use the graph api to create a draft for an email thread. I know that I can create a reply using the users/{email}/messages/createReply, but I didn't figure out how to add this draft to a thread.

Can someone help me out?


r/GraphAPI • • May 26 '25

How to get the email message ID with the /users/{email}/messages endpoint

1 Upvotes

Hello, I am building an automated bot to retrieve message ID that I can use to create a reply to all using Microsoft Graph API.

I don't want to use the /me endpoints because I don't want the user to log in every time a new reply should happen.

I supplied the Mail.ReadWrite permission to the Azure app created for this bot and got the admin to approve. It has the application permission, not the delegated permission.

When I experimented with the /me/messages endpoint, I got the message ID no problem.

However, when I use the /users/{email}/messages endpoint, I don't see the message ID, only the subject and recipient.

Am I missing other permissions? Or is this something I just cannot do?


r/GraphAPI • • May 08 '25

new-mgusercontact bodyparameters hashtable no longer working

1 Upvotes

I've no idea what happened, but I suddenly cannot use the -bodyparameters parameter to add a contact to a user's contacts. I used to build a hashtable called $params with all the information, and simply use that $params variable to quickly populate a new employee's contacts.

Now when I do it, an empty contact is created in the mailbox, but none of the information from the $params variable shows up. Just a whole lot of empty contacts.

Did something change, where I need to use something other than a hashtable, or I need to convert to some sort of special object? I can add information via the various other parameters, such as -GivenName, -Surname, etc. But even doing that I can't add email addresses, since those need to be in hashtable form.


r/GraphAPI • • May 05 '25

Unable to set deleteBlocked via Graph or MgGraph SDK - regression or intentional deprecation?

1 Upvotes

Hi all,

I'm trying to programmatically protect an Azure AD security group from accidental deletion by setting the deleteBlocked property via Microsoft Graph.

No matter what I try, I always get 404 Not Found. Here's the context:

Group created via:

New-MgGroup -DisplayName "TestGroup" `
            -MailEnabled:$false `
            -MailNickname "testgroupxyz" `
            -SecurityEnabled:$true `
            -GroupTypes @()
  • Not mail-enabled

  • Not isAssignableToRole = true

  • Not part of an RMAU

  • resourceProvisioningOptions is empty

  • Created in a clean tenant (not bound to Intune, Teams, etc.)

Permissions:

  • Auth via Connect-MgGraph -Scopes "Group.ReadWrite.All"

  • Using either Update-MgGroup or Invoke-MgGraphRequest

Both fail:

Update-MgGroup -GroupId $id -AdditionalProperties @{ deleteBlocked = $true }

or

Invoke-MgGraphRequest -Method PATCH `
  -Uri "https://graph.microsoft.com/v1.0/groups/$id"` `
  -Body @{ deleteBlocked = $true }

→ returns:

404 Not Found – Resource '' does not exist...

Even though:

Get-MgGroup -GroupId $id

works perfectly, and returns a valid group object.

So... was this feature deprecated?

This used to work (e.g. via Azure AD Graph or MSOnline in the past), and I’ve seen it set on tenant-internal groups (deleteBlocked: true in Graph output). But nothing works anymore - not on new groups, not even with Global Admin permissions (tested via portal as well).

Is this property no longer writeable via Microsoft Graph?

  • Is this an intentional restriction (e.g. since AzureAD → Entra migration)?

  • Or a regression / unannounced change?

If you’ve successfully set deleteBlocked recently - or have internal docs or workarounds - I’d love to hear it.

Thanks!


r/GraphAPI • • May 02 '25

Get-MgBetaCommunicationPresence - anybody tried using it? (via Powershell)

1 Upvotes

I've been trying to use Get-MgBetaCommunicationPresence to get user presence information, every time it just comes back with

Activity: PresenceUnknown

Availability: PresenceUnknown

Also tried with the UserPresence command too.

Initially I did not have permissions granted to the Enterprise app I use for authentication, it gave a error about, that has now been granted and get a response back form the command.


r/GraphAPI • • Apr 30 '25

Use managed Identity to connect with Microsoft graph

1 Upvotes

I have used logic app to query graph api using managed Identity. https://youtu.be/HDeVDYcsxNY


r/GraphAPI • • Apr 25 '25

Filter Question

1 Upvotes

I’m a bit confused and need some help. I’m trying to use the filter for messages by InternetMessageID, but I’m not sure what I’m doing wrong. I’ve seen examples of the code, but I’m missing something. Can you explain what the ‘eq’ means? I don’t think I can put it in the URL because of the spaces. I know it's something simple. Thank you.

https://graph.microsoft.com/v1.0/me/messages?$filter=internetMessageId eq '<encoded_internet_message_id>'

r/GraphAPI • • Apr 13 '25

HTTP 503 enumerating SharePoint sites

1 Upvotes

Hi,
I have a PowerShell script that downloads periodically some data via Graph, but I am unable to get SharePoint information.

The code is

$Headers = @{
'Authorization' = "Bearer $token"
}
$uri = 'https://graph.microsoft.com/v1.0/sites'
$r = Invoke-WebRequest -Uri $uri -Headers $Headers

but the result is

Invoke-WebRequest : The remote server returned an error: (503) Server Unavailable.
At line:1 char:6
+ $r = Invoke-WebRequest -Uri $uri -Headers $Headers
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

The user I use to run the script has Sites.Read permission.

Any idea?

Thank you.


r/GraphAPI • • Apr 01 '25

MS Graph API Excel to PDF Region Format

1 Upvotes

There are anyway in MS Graph API to set region format when converting Excel to PDF to use the correct digit grouping and decimal characters? (ex: "1 234,5" - french format).

I'm using the API /v1.0/drives/{driveId}/items/{itemId}/content?format=pdf

The /settings/regionalAndLanguageSettings API is not an option because it is a server to server integration using Client Id/Client Secret authentication

And formatting cells as numeric "# ##0.0" doesn't work because pdf cames with "1,123.4" (US format)


r/GraphAPI • • Mar 25 '25

Using Graph to get detailed Intune hardware info (Specifically CPU)

1 Upvotes

I'm using Graph to get data from our Intune MDM, its been successful for months getting general Intune and Entra device compliance info.

This week I have been trying to get a more detailed hardware inventory ahead of moving to a new hardware asset management platform (Workwize). After hours of digging around yesterday, I managed to get the device memory information out.

Get-MgBetaDeviceManagementManagedDevice -ManagedDeviceId $DeviceId -Select physicalMemoryInBytes

However, the CPU Model information that I can see in Intune is still eluding me!

In Intune, Device, Monitor, Resource Explorer, CPU, the Model shows things like '12th Gen Intel(R) Core(TM) i5-1240P'.

How can I get this via Graph?


r/GraphAPI • • Mar 20 '25

Trying to run graph commands via PowerShell using user authentication but getting client ID errors.

1 Upvotes

I'm not sure where the hiccup is because I can connect to graph (connect-mggraph) using my credentials just fine.

get-mgcontext shows everything including
Default graph app client ID, tenant ID, interactive auth as the token type, delegated access, as well as the proper scopes.

However, when I run any other command, including get-mguser, I'm met with this error in an interactive auth window popup:

Sign in
Sorry, but we’re having trouble signing you in.
AADSTS900144: The request body must contain the following parameter: 'client_id'.

I've already tried uninstalling graph modules, rebooted, even tried a different device, and app (VSCode instead of ISE), but to no avail.

Any ideas?


r/GraphAPI • • Mar 13 '25

Onedrive file metadata

1 Upvotes

I have an interesting case. I need to retrieve metadata for all files stored in OneDrive across all users, including details like file name, size, and last modified date. However, I do not want access to the actual document content. My current understanding is that the Files.Read.All permission grants access to all documents, which I want to avoid. What permission should I use to achieve this?


r/GraphAPI • • Feb 17 '25

Can you use Github repo's OIDC token in Powershell to Connect-Mggraph?

1 Upvotes

I have a github repo that has a federated credential with Entra. My github actions workflow works perfectly with OIDC.

I would like to know if I could leverage to OIDC token to connect to Mg Graph from a powershell script in the same repo.

Has anyone done this? can you let me know how?


r/GraphAPI • • Feb 08 '25

Asked to deploy to devices but only given user names.

Thumbnail
reddit.com
1 Upvotes

r/GraphAPI • • Feb 06 '25

OneDrive Search Returns No Results when Switched to Application Permissions

1 Upvotes

I have developed a Python script to search for specific files in OneDrive using the Graph API. The goal is to search across multiple user accounts within my tenant. When developing the script I registered the app in Entra and used delegate permissions. Used the script to find files within my own OneDrive and it gets results.

Then I registered a new app in Entra that uses application permissions instead of delegate (same permissions: Files.ReadWrite.All, Sites.ReadWrite.All, User.Read.All), switched the app/client ID in my code, and generated a secret to use in ClientSecretCredential. The searches still run without error but no results are returned when I target my own OneDrive. If is switch back to the old client ID, the searches return results again. So it doesn't appear to be an issue with the code (see a shortened version of the code below).

On the API Permissions page I clicked "Grant admin consent for <tenant>" and all of the permissions show as "Granted".

What am I missing?

async def main(file_name: str, drive_id: str):
    # Initiate GraphClient
    secret = "<secret>"
    client_id = "<client_id>"
    tenant_id = "<tenant_id>"
    client_secret_credential = ClientSecretCredential(client_secret=secret, client_id=client_id, tenant_id=tenant_id)
    graph_scopes = ['https://graph.microsoft.com/.default']
    graph_client = GraphServiceClient(client_secret_credential, graph_scopes)
    # Run searches
    try:
        # Use Graph Search
        request = SearchRequest(
            query=SearchQuery(query_string=file_name),
            entity_types=[EntityType.DriveItem],
            region="NAM",
            share_point_one_drive_options=SharePointOneDriveOptions(
                include_content=[SearchContent.PrivateContent, SearchContent.SharedContent]),
        )
        post_request_body = QueryPostRequestBody(requests=[request])
        search_result_1 = await graph_client.search.query.post(post_request_body)
        # Use OneDrive Search With Q
        search_result_2 = await (graph_client
                               .drives
                               .by_drive_id(drive_id=drive_id)
                               .search_with_q(file_name)
                               .get())
    except APIError as e:
        print(f"Error when searching for OneDrive File {file_name}: {e.primary_message}")
        return None
    except Exception as e:
        print(f"Unknown error occurred when searching for OneDrive File {file_name}: {e.primary_message}")
        return None
    print(len(search_result_1.value))
    print(len(search_result_2.value))

r/GraphAPI • • Jan 30 '25

Read Calendars not working

1 Upvotes

I have granted myself calendars.read and calendars.readbasic but when I attempt to run in powershell get-mgbetausercalendarview it returns access is denied. According to this link Get calendar - Microsoft Graph v1.0 | Microsoft Learn the two of the permissions I've granted should be enough?

Any ideas what other permissions may be needed to pull this data?


r/GraphAPI • • Jan 24 '25

Help with Microsoft Graph API: Unable to Access hardwarePasswordInfo Using Enterprise Application Token

Thumbnail reddit.com
1 Upvotes

r/GraphAPI • • Jan 13 '25

Extension attributes for a serialnumber

1 Upvotes

How to get extension attributes from https://graph.microsoft.com/v1.0/deviceManagement/managedDevices call for a particular serial number


r/GraphAPI • • Jan 09 '25

how to send a Chat message to a user using Microsoft Graph from postman?

1 Upvotes

i used the followig method

POST https://graph.microsoft.com/v1.0/users/UserId/chats/{ChatID}/messages

First i created OneOnOne chat and then with the Chat Id i tried to send a message

I have applied permissions that documentation recommend for the App, but i´m having this issue

"error": {
"code": "Unauthorized",
"message": "Message POST is allowed in application-only context only for import purposes. Refer to https://docs.microsoft.com/microsoftteams/platform/graph-api/import-messages/import-external-messages-to-teams for more details."


r/GraphAPI • • Dec 27 '24

Automate out of office email to all users in tenant

1 Upvotes

r/GraphAPI • • Dec 21 '24

Inexplainable bad request errors

1 Upvotes

Hello!

I have cooked a pretty basic workflow with the Python SDK of Graph and I am seeing a very weird behavior:

The code:

  1. Crawls a SharePoint library

  2. Gets oversized images ids in a list

Iterates over list and:

3. Downloads content and resizes

4. Deletes oversized item

5. Uploads with same name.

The code works except when...it doesn't. Intermittent errors are everyone's favorite right? And here comes the good part.

From my rudimentary logging I see that the function causing the error is the PUT request to create a new item. The replaced item causing the error has a weirdly malformed name: Normal name should be example.jpg but instead it shows as example(0).jpg. The driveItem ID is correct as is the parent ID. Which is weird because the error I get is 400 with message='Bad Request - Error in query syntax.'.

What is even weirder is that rerunning the code handles the previously offending item just fine.

This makes me think of possibly some kind of throttling, however throttling should throw 429 errors instead.

Any ideas welcome! Thank you!