Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Harineeeeeeee
Helper I
Helper I

How to access Dynamics CRM API from PowerBi using Client Id , Client secret and tenant Id using

Hi,

 I am trying to fetch data from Dynamics CRM API to fetch audit info 

 

https://community.dynamics.com/blogs/post/?postid=f40996bf-52a9-417c-8294-bf35b1f53a84 

 

Above is the blog I referred to get API Info, the sample API I used is as,

 

https://{orgname}.crm.dynamics.com/api/data/v9.2/audits

 

Also cross verified that audits logs are enabled the APi works perfect in Dynamics CRM but when I try using this APi in PowerBI which has service principal authentication method gives me error saying no access to target data source?

 

how to resolve this?

should we need to Enable Control user access to environments especially with security groups and licensee? 

please assist on how to consume Dynamics CRM API in PowerBI 

2 ACCEPTED SOLUTIONS

You can validate tokens at jwt.io

 

 

View solution in original post

v-saisrao-msft
Community Support
Community Support

hi @Harineeeeeeee 

As from our previous conversation, to verify the access token, you can use jwt.io. When you authenticate using the service principal, you should receive an access token. Go to jwt.io and paste your access token into the "Encoded" field. The tool will decode the token and display its contents. Look for the "scp" section in the decoded token to ensure it includes the necessary permissions to access the Dynamics CRM API. Generating a login bearer token first and then using that token in your API calls can help resolve the issue by ensuring you have a valid token with the required permissions. 

 

Probably you can generate and login bearer token first and then using that token in your API calls can help resolve the issue. This approach ensures that you have a valid token with the required permissions to access the Dynamics CRM API. By including the bearer token in the Authorization header of your API calls, the API can verify that you have the necessary permissions to access the data. 

If this post clears your doubt, please give us Kudos and consider marking Accepting it as a solution to guide other members in finding it more easily.

View solution in original post

13 REPLIES 13
v-saisrao-msft
Community Support
Community Support

Hi @Harineeeeeeee 

I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please Accept it as a solution and give it a 'Kudos' so others can find it easily.
Thank you.

v-saisrao-msft
Community Support
Community Support

Hi @Harineeeeeeee 
Based on our previous conversation, if the solution I provided works for you, please don't hesitate to reach out if you have any further questions. If my response has resolved your query, kindly accept it as a solution and give it a 'Kudos' to help other members find it easily.

Thankyou.

 

v-saisrao-msft
Community Support
Community Support

hi @Harineeeeeeee 

As from our previous conversation, to verify the access token, you can use jwt.io. When you authenticate using the service principal, you should receive an access token. Go to jwt.io and paste your access token into the "Encoded" field. The tool will decode the token and display its contents. Look for the "scp" section in the decoded token to ensure it includes the necessary permissions to access the Dynamics CRM API. Generating a login bearer token first and then using that token in your API calls can help resolve the issue by ensuring you have a valid token with the required permissions. 

 

Probably you can generate and login bearer token first and then using that token in your API calls can help resolve the issue. This approach ensures that you have a valid token with the required permissions to access the Dynamics CRM API. By including the bearer token in the Authorization header of your API calls, the API can verify that you have the necessary permissions to access the data. 

If this post clears your doubt, please give us Kudos and consider marking Accepting it as a solution to guide other members in finding it more easily.

v-saisrao-msft
Community Support
Community Support

Hi @Harineeeeeeee 
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you.

v-saisrao-msft
Community Support
Community Support

Hi @Harineeeeeeee 
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you.

v-saisrao-msft
Community Support
Community Support

Hi @Harineeeeeeee 

Thanks for posting in the Microsoft forum community. 

As per your query about accessing Dynamics CRM API from PowerBi using Client Id, Client secret, and tenant Id. Here are some steps to resolve your issue: 

  • Check API Permissions: 
    Ensure API permissions are correctly configured in Azure. 
    Register the app in Azure AD and grant it necessary API permissions to access Dynamics CRM API. 
  •  Enable Control User Access: 
       Enable control user access to environments using security groups and licenses. 
       Create security groups, add members, and associate these groups with the environment for the correct access level. 
  •   Use Correct Authentication Method: 
        Use the correct authentication method (service principal) with the required scope in the access token. 
        Verify the access token at jwt.io to ensure the "scp" (scope) section includes necessary permissions. 
  •   Verify Licensing: 
        Ensure the service principle is properly configured in Azure AD and Dynamics 365 to authenticate and access data. 
  •    Validate API Access: 
        Test the API using tools like Postman to confirm that the service principal can retrieve data. 
  •    Power BI Configuration: 
        Configure the data source in Power BI to use the service principal authentication method. 
        Ensure the "Token Audience URI" matches the Dynamics CRM API endpoint. 

 If my response addressed your question, please mark my post as a solution to assist others. 
Additionally, if you find my response helpful, consider giving "Kudos". 

lbendlin
Super User
Super User

how did you register the app permission scope? delegated?

@lbendlin When you say app permission scope, is that in Dynamics CRM? 
if yes how to do that ?

 

No, in Azure, when you created the app that gave you the client ID and secret

Yes that gave me the client id and client secret and when I query data tables using dataverse for the same environment of dynamics crm using the service principal authentication it works only for the API it didn't work 

check the access token ( at jwt.io ) - most likely the "scp"  (scope) section is missing or incomplete.

Hi @v-saisrao-msft 

 

@when you refer to use correct authentication method, I am using service principal to authenticate but how to verify the access token? Where can I find that??could you please elaborate 

 

Also I was suggested to generate login bearer token first and then providing that token as part of the api calls, will that help to resolve this issue? 

You can validate tokens at jwt.io

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.