AZURE B2C - Register New Application MS Graph - API Permissions

Ignacio Herrero Jiménez 106 Reputation points
2022-07-04T11:11:08.867+00:00

How Can I to add "API Permissions" using Microsoft Graph when I register a new application in Azure B2C.

I need to add "openid" and "offline_access" (type = delegated)

        GraphServiceClient graphClient = new GraphServiceClient(authProvider);  

        var application = new Application  
        {  
            DisplayName = name,                 
            Web = new WebApplication  
            {  
                RedirectUris = new string[] { "https://jwt.ms/" },  
                ImplicitGrantSettings = new ImplicitGrantSettings { EnableAccessTokenIssuance = true, EnableIdTokenIssuance = true }  
            }  
        };  

        var app = await graphClient.Applications.Request().AddAsync(application);  

217309-image.png

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,058 questions
Microsoft Entra External ID
Microsoft Entra External ID
A modern identity solution for securing access to customer, citizen and partner-facing apps and services. It is the converged platform of Azure AD External Identities B2B and B2C. Replaces Azure Active Directory External Identities.
3,034 questions
0 comments No comments
{count} votes

Accepted answer
  1. CarlZhao-MSFT 45,186 Reputation points
    2022-07-05T02:45:53.687+00:00

    Hi @Ignacio Herrero Jiménez

    You cannot grant graph permissions while creating an application, you can only grant graph permissions to an application after it has been created.

    GraphServiceClient graphClient = new GraphServiceClient( authProvider );  
      
    var application = new Application  
    {  
    	RequiredResourceAccess = new List<RequiredResourceAccess>()  
    	{  
    		new RequiredResourceAccess  
    		{  
    			ResourceAppId = "00000003-0000-0000-c000-000000000000",  
    			ResourceAccess = new List<ResourceAccess>()  
    			{  
    				new ResourceAccess  
    				{  
    					Id = Guid.Parse("7427e0e9-2fba-42fe-b0c0-848c9e6a8182"),  
    					Type = "Scope"  
    				},  
    				new ResourceAccess  
    				{  
    					Id = Guid.Parse("37f7f235-527c-4136-accd-4a02d197296e"),  
    					Type = "Scope"  
    				}  
    			}  
    		}  
    	}  
    };  
      
    await graphClient.Applications["{app object id}"]  
    	.Request()  
    	.UpdateAsync(application);  
    

    217488-image.png


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


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.