How to fix "403 forbidden" while trying to access MS Graph API during creation of User Flow using PowerShell or Bash in Azure AD B2C Tenant?

Payel Ganguly 20 Reputation points Microsoft Employee
2024-07-23T13:09:04.6033333+00:00

Hi all, I need help with API permissions for MS Graph API while creating User Flow using PowerShell. 

 Context: I am trying to create User Flow in Azure AD B2C tenant, but while trying to send Graph API requests using Invoke-MgGraphRequest command, I am getting error HTTP/1.1 403 Forbidden - "code":"AADB2C","message":"User authorization failed. You must have access to <b2c_tenant_id>".

 After adding Connect-MgGraph -Scopes "IdentityUserFlow.ReadWrite.All" command in the script, the error message changes to "HTTP/1.1 500 Internal Server Error - {"code":"InternalServerError","message":"Unable to find target address".

 I have added delegated IdentityUserFLow.ReadWrite.All API permissions and tried the 1st step as well, but no luck.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,005 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,509 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
21,702 questions
0 comments No comments
{count} votes

Accepted answer
  1. Navya 10,785 Reputation points Microsoft Vendor
    2024-07-24T04:38:11.8566667+00:00

    Hi @Payel Ganguly

    I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to "Accept " the answer.

    Issue:

    How to fix "403 forbidden" while trying to access MS Graph API during creation of User Flow using PowerShell or Bash in Azure AD B2C Tenant?

    Solution:

    Issue resolved by @Payel Ganguly

    The issue was resolved by adding the "IdentityUserFlow.ReadWrite.All" application permission.

    If you have any other questions or are still running into more issues, please let me know. Thank you again for your time and patience throughout this issue.

    Thanks,

    Navya.

    Please remember to "Accept Answer" if any answer/reply helped, so that others in the community facing similar issues can easily find the solution.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Payel Ganguly 20 Reputation points Microsoft Employee
    2024-07-23T15:44:12.11+00:00

    We need to add IdentityUserFLow.ReadWrite.All Application permission as well, that resolved my error.

    0 comments No comments

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.