Office365 세입자의 모든 사용자와 함께 드롭 다운을 만들려고합니다. Azure AD에서 앱을 만들고 필요한 모든 권한을주었습니다. 나는 사실, 애플 리케이션 및 위임 Microsoft Graph에 대한 모든 권한을 주었다. 모두들.비 관리자 용 Microsoft Graph API 사용 권한?
그런 다음 모든 사용자에게 https://graph.microsoft.com/v1.0/users
을 쿼리하는 스크립트를 작성했습니다.
필자는 세입자 관리자가 권한을 받아 UI의 사용자 목록을 출력하도록했습니다. 내가 관리자 모르겠지만 관리자
을 위해 잘 작동 나는 다음과 같은 오류 페이지로 이동하는 경우 :
나는이 더 낮은 권한을 가진 사용자를 위해 작동하는지 알 필요가This application requires application permissions to another application. Consent for application permissions can only be performed by an administrator. Sign out and sign in as an administrator or contact one of your organization's administrators.
. 내가 API 요청을 이해하고 Azure에서 응용 프로그램에 부여 된 권한으로 응용 프로그램이 실행 중입니다. 따라서 사용자가 읽기 전용으로되어 있어도 사용자가 요청을 실행하지 않아도 설정 한 응용 프로그램에서 실행됩니다. 그렇다면 권한과 관련하여 오류가 발생하는 이유는 무엇입니까? 마이크로 소프트 그래프 허가/범위의 두 종류가 있습니다
(function() {
"use strict";
// Some samples will use the tenant name here like "tenant.onmicrosoft.com"
// I prefer to user the subscription Id
var subscriptionId = "metenant.onmicrosoft.com";
// Copy the client ID of your AAD app here once you have registered one, configured the required permissions, and
// allowed implicit flow https://msdn.microsoft.com/en-us/office/office365/howto/get-started-with-office-365-unified-api
var clientId = "cccb1f2f-xxx-x-xxxxx-x-x-x-x-x-";
window.config = {
// subscriptionId: subscriptionId,
clientId: clientId,
postLogoutRedirectUri: window.location.origin,
endpoints: {
graphApiUri: 'https://graph.microsoft.com'
},
cacheLocation: 'localStorage' // enable this for IE, as sessionStorage does not work for localhost.
};
var authContext = new AuthenticationContext(config);
// Check For & Handle Redirect From AAD After Login
var isCallback = authContext.isCallback(window.location.hash);
authContext.handleWindowCallback();
if (isCallback && !authContext.getLoginError()) {
window.location = authContext._getItem(authContext.CONSTANTS.STORAGE.LOGIN_REQUEST);
}
// If not logged in force login
var user = authContext.getCachedUser();
// NOTE: you may want to render the page for anonymous users and render
// a login button which runs the login function upon click.
if (!user) authContext.login();
// Acquire token for Files resource.
authContext.acquireToken(config.endpoints.graphApiUri, function (error, token) {
// Handle ADAL Errors.
if (error || !token) {
console.log('ADAL error occurred: ' + error);
return;
}
// Execute GET request to Files API.
var filesUri = config.endpoints.graphApiUri + "/v1.0/users";
$.ajax({
type: "GET",
url: filesUri,
headers: {
'Authorization': 'Bearer ' + token,
}
}).done(function (response) {
console.log('Successfully fetched from Graph.');
console.log(response);
var container = $(".container")
container.empty();
$.each(response.value, function(index, item) {
container.append($('<li>').text(item.displayName + " " + item.mail + " " + item.mobilePhone))
})
}).fail(function (response) {
var err = JSON.parse(response.responseText)
console.log('Failed:', err.error.message);
});
});
})();
현재 로그인 한 사용자의 토큰을 Graph API에 전달하는 것처럼 보입니다. 임차인의 서비스 주체에 적절한 권한을 부여한 다음 서비스 주체 토큰을 획득하고이를 Graph 호출에 사용할 수 있습니다. – Aram
ADAL을 사용하고 있고 앱의 clientID가 그래프 API에 대한 앱 로그인에서 전달되고 현재 사용자가 아니라면 지나치지 않아야합니까? 내가 이것을 사용하기 위해 사용하는 코드를 추가했습니다. – Batman