microsoftgraph / microsoftgraph/msgraph-sdk-java

Cannot create online meeting with Enterprise Application

未關閉
#2,369 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

status:waiting-for-triage type:bug
主要語言
Java
星號
444
分支
154
平均合併
18 小時 28 分鐘
30 天內合併 PR
4

描述

Describe the bug

We're unable to create an online meeting using the Microsoft Graph SDK with a service principal. We're following the application permissions flow (not delegated) and calling the Graph API with the correct scopes and payload, but the request fails withthe follwing error

com.microsoft.graph.models.odataerrors.ODataError: No application access policy found for this app.
Expected behavior

Online meeting created

How to reproduce
  • Added deps
<dependency>
            <groupId>com.azure</groupId>
            <artifactId>azure-identity</artifactId>
            <version>1.15.4</version>
        </dependency>
        <dependency>
            <groupId>com.microsoft.graph</groupId>
            <artifactId>microsoft-graph</artifactId>
            <version>6.36.0</version>
        </dependency>
  • Created an Enterprise Application and corresponding Service Principal.
  • Granted all required application permissions, including:
    • OnlineMeetings.ReadWrite.All
    • User.Read.All
    • Calendars.ReadWrite
    • All permissions have been admin-consented.
  • Created a mail-enabled security group and added all relevant users to it.
  • Used the following code to try to create an online meeting:
@Override
    public Event createCall(CallDTO callData) throws TechnicalUserIsNullException {
        try {
            GraphServiceClient graphClient = accessTokenGenerationService.getGraphServiceClient();

            User organizerUser = accessTokenGenerationService.getTechnicalUser();

            // 2.Create online meeting
            OnlineMeeting meeting = createOnlineMeeting(callData, graphClient);
            OnlineMeeting createdMeeting = graphClient.users()
                    .byUserId(organizerUser.getId())
                    .onlineMeetings()
                    .post(meeting);

        } catch (ODataError error) {
            log.error("Error calling Microsoft Graph API: {} - {} - {}", error.getError().getCode(), error.getError().getMessage(), error.getError().getTarget());
            log.error("Error calling Microsoft Graph API Inner clientRequestId: {} - requestId: {} - OdataType: {}", error.getError().getInnerError().getClientRequestId(), error.getError().getInnerError().getRequestId(), error.getError().getInnerError().getOdataType());
            throw error;
        } catch (Exception ex) {
            log.error("Error creating Teams call: {}", ex.getLocalizedMessage(), ex);
            throw ex;
        }
    }


    private OnlineMeeting createOnlineMeeting(CallDTO callData, GraphServiceClient graphClient) {
        OnlineMeeting meeting = new OnlineMeeting();
        meeting.setStartDateTime(OffsetDateTime.of(callData.from(), ZoneOffset.UTC));
        meeting.setEndDateTime(OffsetDateTime.of(callData.to(), ZoneOffset.UTC));
        meeting.setSubject(callData.title());
        meeting.setParticipants(buildMeetingParticipants(callData.organizerEmail(), callData.otherParticipants(), graphClient));
        meeting.setAllowedLobbyAdmitters(AllowedLobbyAdmitterRoles.OrganizerAndCoOrganizersAndPresenters);
        meeting.setRecordAutomatically(callData.recordCall());
        return meeting;
    }

    private MeetingParticipants buildMeetingParticipants(String organizer, List<String> otherParticipants, GraphServiceClient graphClient) {
        MeetingParticipants participants = new MeetingParticipants();
        participants.setOrganizer(createMeetingParticipantInfo(organizer, graphClient, true));
        participants.setAttendees(otherParticipants.stream()
                .map(email -> createMeetingParticipantInfo(email, graphClient, false))
                .toList());
        return participants;
    }

Then i created the application policy using powershell on portal azure

Install-Module ExchangeOnlineManagement
Connect-ExchangeOnline
New-ApplicationAccessPolicy `
    -AppId 41874eeb-9f6f-45b6-bb20-becdcb0d461e `
    -PolicyScopeGroupId group-for-meeintg@example.com `
    -AccessRight RestrictAccess `
    -Description "A sample description"
SDK Version

6.36.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output
Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 GraphServiceClient users().byUserId(...).onlineMeetings().post(meeting) 呼叫和回報的 application access policy 錯誤開始。檢查 issue 中描述的 service-principal 權限和 Exchange Online 原則設定,然後根據記載的 application-permission 流程驗證要求。完成的標準是確定故障是由 SDK 要求還是外部原則設定造成的。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
azure, java
領域
api, authentication, authorization
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
25/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。