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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Issues Embedding Report in Salesforce

Objective: Embed PowerBI report in Salesforce

 

Issues: API Authentication/Stale token stored in Salesforce

 

Details:

 

I had followed the blog post on how embedding within Salesforce found here: https://powerbi.microsoft.com/en-us/blog/embedding-a-power-bi-report-into-salesforce/

 

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: https://community.powerbi.com/t5/Developer/Power-BI-REST-API-using-postman-generate-embed-token/m-p/... ), 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": [

        70002,

        50126

    ],

 

}

 

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": [

        70002,

        50053

    ],

 

}

 

Despite being the correct credentials.

 

 

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

 

 

3 REPLIES 3
v-jiascu-msft
Employee
Employee

Hi @Anonymous,

 

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,

Dale

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.
Anonymous
Not applicable

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: https://app.powerbi.com/embedsetup/userownsdata (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:  https://github.com/Microsoft/BusinessPlatformApps/tree/dev/Samples/Salesforce/EmbedPowerBIReport
  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:  OurSalesforceInstance.com/apex/PowerBI
  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 ( https://www.linkedin.com/pulse/success-power-bi-embedded-salesforce-fred-kaffenberger/ ) 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.

 

Thanks! 

Anonymous
Not applicable

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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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