Showing results for 
Search instead for 
Did you mean: 
ToC Frequent Visitor
Frequent Visitor

Issues Embedding Report in Salesforce

Objective: Embed PowerBI report in Salesforce


Issues: API Authentication/Stale token stored in Salesforce




I had followed the blog post on how embedding within Salesforce found here:


And was ultimately successful in getting the page to render in Salesforce, but only after hard coding values like client_id and client_secret in the Apex Classes (there was an error in my definition of the Custom Setting that caused accessing the values to fail).


While reconstructing the provided code, one of the trouble shooting steps I took ultimately broke the embedding. 


So, there are two problems.


A. The authentication token stored in Salesforce after hard-coding the client info is no longer valid (I recreated the app in AAD as another trouble shooting step)

 - Despite attempts to invoke the token grant process to create a new token, I was never able to successfully overwrite the one stored 

- Now I get a 403 Forbidden error in the console logs when trying to load the VisualForce page



B. In trying to learn more about the API through testing with Postman (based on this post: ), I've been recieving errors initially of the form:



    "error": "invalid_grant",

    "error_description": "AADSTS70002: Error validating credentials. AADSTS50126: Invalid username or password

    "error_codes": [







And now:


    "error": "unauthorized_client",

    "error_description": "AADSTS70002: Error validating credentials. AADSTS50053: You've tried to sign in too many times with an incorrect user ID or password.

    "error_codes": [







Despite being the correct credentials.



Any help is appreciated and I'm happy to provide more detail if necessary.



Microsoft v-jiascu-msft

Re: Issues Embedding Report in Salesforce

Hi @ToC,


Regarding to issue A:

1. The client info, like client id and client secret, is surely stable. So you can hard-code them. Did you get error message that the client info is invalid?

2. Did you upload all the things in the guide post?

Regarding to issue B:

Can you provide more info? Or I would suggest you open a support ticket here.


Best Regards,


Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
ToC Frequent Visitor
Frequent Visitor

Re: Issues Embedding Report in Salesforce

Hi @v-jiascu-msft,


Thanks for getting back to me! 


1. I was able to successfully embed the report when the values were hard coded. This led me to believe the values in the Custom Setting were wrong so I deleted the Custom Setting and the App in AAD and recreated both, however, the issue ended up being that I named the Custom Setting  'PowerBI' instead of PowerBI.  Now that the Custom Setting is named properly, Salesforce can access client_id, client_secret, etc, but the AccessToken and RefreshToken that are stored are for a different App so the authentication fails. I've been unable to overwrite the AccessToken and RefreshToken stored by Salesforce despite attempts to re-initiate the login process.


Research into how  to overwrite OAuth tokens in Salesforce hasn't been fruitful so I'm hoping someone who understands the authenication process better might have some insight.


2. I have followed all of the steps in the guide. After the hard coded version worked I made sure all of the necessary parts exist within Salesforce and are named correctly.



As for B, I'll look into a support ticket for now.



Thank you for your time.

ToC Frequent Visitor
Frequent Visitor

Re: Issues Embedding Report in Salesforce

Background information: The report is located in a Premium capacity workspace and the hope is to distribute the report to the Sales team without needing to grant licenses.


Some additional information about the steps I took:


  1. Register App with Azure AD using onboarding tool: (This step wasn’t done as the service account, not sure of the implications of that)
  2. Grant permissions in AAD as Service Account (master account, admin of workspace)
  3. Create Salesforce Custom Setting OAuthApp_pbi
  4. Populate Custom Setting for PowerBI with AAD endpoints along with client id/secret
  5. Create OAuthController and PowerBIController Apex Classes with code from:
  6. Add Azure AD to Salesforce’s Remote Site Settings
  7. Create Visualforce Page with code from GitHub repo linked above
  8. Add Report ID to Visualforce page code
  9. Navigate to Visualforce page located at:
  10. In pop up window, log in as the Service Account



Once all of these steps have been completed the iframe renders within Salesforce, but displays "This content is not available". Based on this blog post ( ) my next debugging step would be to use Fiddler to inspect the requests/replies. I'll work on that, but hopefully this additional information might point out where I went wrong.


Let me know if you have any ideas.



Helpful resources

New Topics Started Badges Coming

New Topics Started Badges Coming

We're releasing new versions of the badge that everyone's talking about. ;) Check your inbox for notifications.

MBAS 2020

Save the new date (and location)!

Our business applications community is growing—so we needed a different venue, resulting in a new date and location. See you there!

Difinity Conference

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Kudoed Authors (Last 30 Days)