how to create Print Job using Graph API with Application Permissions through .Net Core Web API?

Suresh Amsala 20 Reputation points
2025-01-01T08:52:33.42+00:00

Hi

I am trying to integrate Universal Print with the Microsoft Graph API in a .NET Core Web API application.

I have Azure Subscription and enable Universal Print on my Azure tenant and registered printer in Universal Print.

Registered application in the Azure portal and added the necessary Delegated and Application permissions (e.g., PrintJob.ReadWrite, Printer.ReadWrite.All) with Grant Admin Consent under Microsoft Graph API.

I am getting "the token does not have one or more required security scopes" at below code.

I have decrypted the token by using jwt.ms and observed that I have sufficient roles those are: "roles": [ "Files.ReadWrite.AppFolder", "Printer.Read.All", "Printer.ReadWrite.All", "PrintJob.Manage.All", "PrintJob.ReadWriteBasic.All", "PrintJob.Read.All", "PrintSettings.Read.All", "PrintJob.ReadWrite.All", "Files.ReadWrite.All", "Files.Read.All", "PrintTaskDefinition.ReadWrite.All", "PrintJob.ReadBasic.All" ] Still I am getting the error.

var res = await _graphServiceClient.Print.Printers[pId].Jobs.PostAsync(pjob);

I am able to make it work this by using .Net Core Web App OpenIDConnect approach and it is pulling Delegated Permissions as scope, and it is asking user consent when running the application.

I would like to make it work with "Application Permissions" (app-only) because this will run in the background as Web API and from my org multiple users will give print request and every time, we could not ask user consent.

I went through the Microsoft Graph API and Universal Print documentation and tried in AI tools but unfortunately, I could not find a way to do this by using Application Permissions in WEB API.

If anyone suggest an approach or solutions that would be appreciated.

Thanks,

Suresh

Developer technologies ASP.NET ASP.NET API
Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2025-01-02T01:34:18.1933333+00:00

    Hello Suresh Amsala,

    Thank you for reaching out to Microsoft Support!

    Looking through the documentation, it is unfortunate that the Graph API endpoint does not support Application permissions, only delegated permissions, as shown below:

    User's image

    See this document for more details:

    https://learn.microsoft.com/en-us/graph/api/printer-post-jobs?view=graph-rest-1.0&tabs=csharp

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.