Forum Discussion
Power BI REST API using postman - generate embed token.
- 8 years ago
insoldev wrote:
Hello - currently working through trying to get an embed token using the Power BI rest api. I am following the guidance as on this page. https://msdn.microsoft.com/en-us/library/mt784614.aspx.
ultimately, I am trying to achieve the outcome of using javascript to host a Power BI report in the new model as per https://community.powerbi.com/t5/Developer/Embedding-without-hard-coding-master-credentials-app-owns-data/m-p/296611#M8734 as per Eric_Zhang suggestion.
I am not getting an embed token - I am simply getting this response. Clearly I've missed something - I am using my client secret as the bearer token.
The bearer token requires an access token, not the client secret. You need to follow this link to register a Native app rather than a server-side web app for Power BI Embedded cases and grant sufficient permissions.
Then to get the access token, you can call the POST API in POSTMAN as
POST /common/oauth2/token HTTP/1.1 Host: login.windows.net Cache-Control: no-cache Content-Type: application/x-www-form-urlencoded client_id={client id}&grant_type=password&resource=https%3A%2F%2Fanalysis.windows.net%2Fpowerbi%2Fapi&username={your power bi account}&password={your Power BI password}With the above access_token, you can call the GenerateToken API.
By the way, using POSTMAN is recommended for testing/debug purpose, what would you like in your case?
insoldev wrote:
Hello - currently working through trying to get an embed token using the Power BI rest api. I am following the guidance as on this page. https://msdn.microsoft.com/en-us/library/mt784614.aspx.
ultimately, I am trying to achieve the outcome of using javascript to host a Power BI report in the new model as per https://community.powerbi.com/t5/Developer/Embedding-without-hard-coding-master-credentials-app-owns-data/m-p/296611#M8734 as per Eric_Zhang suggestion.
I am not getting an embed token - I am simply getting this response. Clearly I've missed something - I am using my client secret as the bearer token.
The bearer token requires an access token, not the client secret. You need to follow this link to register a Native app rather than a server-side web app for Power BI Embedded cases and grant sufficient permissions.
Then to get the access token, you can call the POST API in POSTMAN as
POST /common/oauth2/token HTTP/1.1
Host: login.windows.net
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded
client_id={client id}&grant_type=password&resource=https%3A%2F%2Fanalysis.windows.net%2Fpowerbi%2Fapi&username={your power bi account}&password={your Power BI password}
With the above access_token, you can call the GenerateToken API.
By the way, using POSTMAN is recommended for testing/debug purpose, what would you like in your case?
Hi, i am able to create access token but when i create workspace in powerbi its creating but its creating under service principle as admin, but when i create workspace with the token what i got from try it in microsoft its creating workspace under my name, how to get access token which creates workspace under my name as admin and not unser service principle. please give me an solution asap, thanks.