Forum Discussion

aykhandelwal's avatar
aykhandelwal
Microsoft Employee
9 months ago
Solved

created a custom connector to call a API using oauth: received 403 as response.

Hi Team,  I want to call an API hosted azure from my powerBI workspace since that data is needed in our dashboards, we need an auth token to call the API, a curl to that API would look like this ...
  • v-kpoloju-msft's avatar
    9 months ago

    Hi aykhandelwal,

    Thank you for reaching out to the Microsoft Fabric Community Forum. Also, thanks to vojtechsima, for his inputs on this thread.

    From your description, it looks like you are trying to call an Azure-hosted API from Power BI using OAuth authentication. Since you’re getting a 403 (Forbidden) response, it typically indicates that the token being used doesn’t have the right permissions or configuration to access the API.

    To resolve this, you will need to ensure your Azure AD app registrations and Power BI connector are correctly set up for OAuth2. Here are the steps might be helpful

    Expose your API in Azure AD: In the Azure Portal, go to App registrations → your API app → Expose an API. Define an App ID URI (e.g., api://<your-api-client-id>) and add a scope (for example, api.read).
    https://learn.microsoft.com/en-us/entra/identity-platform/quickstart-configure-app-expose-web-apis

    Register your Power BI client app: Create (or use an existing) App registration for Power BI. Under API Permissions, add delegated permission to your API (e.g., api.read). Grant admin consent so that Power BI can use this token to access your API.
    https://learn.microsoft.com/en-us/entra/identity-platform/quickstart-configure-app-access-web-apis

    In your custom connector, configure OAuth2 using:

    authorization_uri = "https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/authorize"
    token_uri = "https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/token"
    scope = "api://<your-api-client-id>/.default"
    


    This ensures Power BI requests a valid token from Azure AD and sends it automatically in the Authorization header.

    Reconnect to your API from Power BI Desktop, sign in using your Azure AD credentials, and try refreshing the data.

    Hope this clears it up. Let us know if you have any doubts regarding this. We will be happy to help.

    Thank you for using the Microsoft Fabric Community Forum.