우리는 SaaS 제품에 보고서/대시 보드를 포함 할 수 있도록 this Power BI article을 따르려고했습니다. 특히 3 단계 '소스 토큰 만들기'에서 멈추었습니다. 보고서를 검색하는 요청이 궁극적으로 API에 제출 될 때 우리는하지만 잘 베어러 토큰을 얻을 수있어Power BI API에 연결할 때 'Forbidden (403)'수신
우리가 나타납니다 조작
private static string clientId = "...";
private static string secretKey = "...";
private static string groupId = "...";
static void Main(string[] args)
{
string resourceUri = "https://analysis.windows.net/powerbi/api";
string authorityUri = "https://login.windows.net/common/oauth2/authorize";
ClientCredential credential = new ClientCredential(clientId, secretKey);
AuthenticationContext authContext = new AuthenticationContext(authorityUri);
var token = authContext.AcquireTokenAsync(resourceUri, credential).Result.AccessToken;
var tokenCredentials = new TokenCredentials(token, "Bearer");
using (var client = new PowerBIClient(new Uri("https://api.powerbi.com/"), tokenCredentials))
{
var reports = client.Reports.GetReportsInGroupWithHttpMessagesAsync(groupId);
// !!! - Here's where the exception is thrown
// !!! -- Operation returned an invalid status code 'Forbidden'
var report = reports.Result.Body;
}
}
'금지'잘못된 상태 코드를 반환 는 여기에 우리가 시도한 작업은 다음과 같습니다
- 필요한 권한이 부여 된 (우리는 우리가 아무것도 누락하지 않을 수 있도록 모든을 확인했습니다). 여기에는 Windows Azure Active Directory/Power BI 서비스가 포함됩니다.
- 클라이언트 ID, 비밀 키 및 그룹 ID가 정확한지 확인했습니다.
- Power BI 작업 공간은 비공개이지만 중요한 것은 아닌지 확인하기 위해 공개 작업을 시도했습니다.
- 마지막으로 코드를 통해받은 토큰은 powerbi.com의 토큰과 일치합니다.
Nan Yu. 그러나 이것은 내 샘플에서 얻은 것과 정확히 동일한 토큰을 얻습니다. 요청한 본문에 'client_secret or client_assertion'매개 변수가 포함되어야합니다. 제안 된 온라인 제안은 '기본 응용 프로그램'을 만들 것을 제안하지만이 역시 나에게 오류를 남깁니다 (UnAuthorized) – leemac
웹 서버와 같은 기밀 클라이언트는 직접 사용자 자격 증명을 사용할 수 없습니다. "Unauthorized"오류가 발생하면 –
Nan을 보내 주시면 감사하겠습니다. 우리는 Microsoft 담당자와 이야기하고 위의 내용을 자세히 설명했습니다.자습서에 설명 된대로 웹 응용 프로그램이 아닌 원시 클라이언트 응용 프로그램을 사용해야했습니다. 매우 혼란 스럽지만 작동하는 것 같습니다. 무엇이 우리를 버렸는지는 앱을 등록 할 때 "네이티브 (데스크톱/모바일/기타)"라고 말한 것입니다. – leemac