I have solved the problem by adding the credentials (bold) to EmbedSample > Web.config:
<appSettings>
<add key="powerbi:AccessKey" value="X==" />
<add key="powerbi:Username" value="X" />
<add key="powerbiassword" value="X" />
<add key="powerbi:ApiUrl" value="https://api.powerbi.com" />
<add key="powerbi:WorkspaceCollection" value="X" />
<add key="powerbi:WorkspaceId" value="Xcc" />
</appSettings>
and to EmbedSample > DashboardController.cs:
public class DashboardController : Controller
{
private readonly string workspaceCollection;
private readonly string username;
private readonly string password;
private readonly string workspaceId;
private readonly string accessKey;
private readonly string apiUrl;
public DashboardController()
{
this.workspaceCollection = ConfigurationManager.AppSettings["powerbi:WorkspaceCollection"];
this.username = ConfigurationManager.AppSettings["powerbi:Username"];
this.password = ConfigurationManager.AppSettings["powerbiassword"];
this.workspaceId = ConfigurationManager.AppSettings["powerbi:WorkspaceId"];
this.accessKey = ConfigurationManager.AppSettings["powerbi:AccessKey"];
this.apiUrl = ConfigurationManager.AppSettings["powerbi:ApiUrl"];
}
Although I have started to get "Debug Assert failed: Warning: Feature switches have not been registered yet so switch values may not be correct". It seems it has something to do with the PowerBI update in March.
More about this issue: