Skip to content

Commit 9d27203

Browse files
Bump msgraph-sdk from 1.1.0 to 1.16.0 (#2254)
* Bump msgraph-sdk from 1.1.0 to 1.16.0 Bumps [msgraph-sdk](https://github.com/microsoftgraph/msgraph-sdk-python) from 1.1.0 to 1.16.0. - [Release notes](https://github.com/microsoftgraph/msgraph-sdk-python/releases) - [Changelog](https://github.com/microsoftgraph/msgraph-sdk-python/blob/main/CHANGELOG.md) - [Commits](microsoftgraph/msgraph-sdk-python@v1.1.0...v1.16.0) --- updated-dependencies: - dependency-name: msgraph-sdk dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * Updates for latest MS Graph SDK --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Pamela Fox <[email protected]>
1 parent 431bbe6 commit 9d27203

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
lines changed

app/backend/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ msal-extensions==1.2.0
193193
# via azure-identity
194194
msgraph-core==1.1.2
195195
# via msgraph-sdk
196-
msgraph-sdk==1.1.0
196+
msgraph-sdk==1.16.0
197197
# via -r requirements.in
198198
msrest==0.7.1
199199
# via azure-monitor-opentelemetry-exporter

scripts/auth_common.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
async def get_application(graph_client: GraphServiceClient, client_id: str) -> Optional[str]:
99
try:
1010
app = await graph_client.applications_with_app_id(client_id).get()
11+
if app is None:
12+
return None
1113
return app.id
1214
except APIError:
1315
return None

scripts/auth_init.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
import random
55
import subprocess
6+
import uuid
67
from typing import Tuple
78

89
from azure.identity.aio import AzureDeveloperCliCredential
@@ -27,8 +28,12 @@
2728

2829
async def create_application(graph_client: GraphServiceClient, request_app: Application) -> Tuple[str, str]:
2930
app = await graph_client.applications.post(request_app)
31+
if app is None:
32+
raise ValueError("Failed to create application")
3033
object_id = app.id
3134
client_id = app.app_id
35+
if object_id is None or client_id is None:
36+
raise ValueError("Created application has no ID or client ID")
3237

3338
# Create a service principal
3439
request_principal = ServicePrincipal(app_id=client_id, display_name=app.display_name)
@@ -40,8 +45,12 @@ async def add_client_secret(graph_client: GraphServiceClient, app_id: str) -> st
4045
request_password = AddPasswordPostRequestBody(
4146
password_credential=PasswordCredential(display_name="WebAppSecret"),
4247
)
43-
result = await graph_client.applications.by_application_id(app_id).add_password.post(request_password)
44-
return result.secret_text
48+
password_credential = await graph_client.applications.by_application_id(app_id).add_password.post(request_password)
49+
if password_credential is None:
50+
raise ValueError("Failed to create client secret")
51+
if password_credential.secret_text is None:
52+
raise ValueError("Created client secret has no secret text")
53+
return password_credential.secret_text
4554

4655

4756
async def create_or_update_application_with_secret(
@@ -94,7 +103,7 @@ def server_app_permission_setup(server_app_id: str) -> Application:
94103
known_client_applications=[],
95104
oauth2_permission_scopes=[
96105
PermissionScope(
97-
id="7b207263-0c4a-4127-a6fe-38ea8c8cd1a7",
106+
id=uuid.UUID("{7b207263-0c4a-4127-a6fe-38ea8c8cd1a7}"),
98107
admin_consent_display_name="Access Azure Search OpenAI Chat API",
99108
admin_consent_description="Allows the app to access Azure Search OpenAI Chat API as the signed-in user.",
100109
user_consent_display_name="Access Azure Search OpenAI Chat API",
@@ -111,15 +120,15 @@ def server_app_permission_setup(server_app_id: str) -> Application:
111120
resource_app_id="00000003-0000-0000-c000-000000000000",
112121
resource_access=[
113122
# Graph User.Read
114-
ResourceAccess(id="e1fe6dd8-ba31-4d61-89e7-88639da4683d", type="Scope"),
123+
ResourceAccess(id=uuid.UUID("{e1fe6dd8-ba31-4d61-89e7-88639da4683d}"), type="Scope"),
115124
# Graph email
116-
ResourceAccess(id="64a6cdd6-aab1-4aaf-94b8-3cc8405e90d0", type="Scope"),
125+
ResourceAccess(id=uuid.UUID("{64a6cdd6-aab1-4aaf-94b8-3cc8405e90d0}"), type="Scope"),
117126
# Graph offline_access
118-
ResourceAccess(id="7427e0e9-2fba-42fe-b0c0-848c9e6a8182", type="Scope"),
127+
ResourceAccess(id=uuid.UUID("{7427e0e9-2fba-42fe-b0c0-848c9e6a8182}"), type="Scope"),
119128
# Graph openid
120-
ResourceAccess(id="37f7f235-527c-4136-accd-4a02d197296e", type="Scope"),
129+
ResourceAccess(id=uuid.UUID("{37f7f235-527c-4136-accd-4a02d197296e}"), type="Scope"),
121130
# Graph profile
122-
ResourceAccess(id="14dad69e-099b-42c9-810b-d002981feec1", type="Scope"),
131+
ResourceAccess(id=uuid.UUID("{14dad69e-099b-42c9-810b-d002981feec1}"), type="Scope"),
123132
],
124133
)
125134
],
@@ -128,6 +137,10 @@ def server_app_permission_setup(server_app_id: str) -> Application:
128137

129138

130139
def client_app(server_app_id: str, server_app: Application, identifier: int) -> Application:
140+
if server_app.api is None:
141+
raise ValueError("Server app does not have an API")
142+
if server_app.api.oauth2_permission_scopes is None or len(server_app.api.oauth2_permission_scopes) == 0:
143+
raise ValueError("Server app does not have any permission scopes")
131144
return Application(
132145
display_name=f"Azure Search OpenAI Chat Client App {identifier}",
133146
sign_in_audience="AzureADMyOrg",
@@ -150,7 +163,7 @@ def client_app(server_app_id: str, server_app: Application, identifier: int) ->
150163
RequiredResourceAccess(
151164
resource_app_id="00000003-0000-0000-c000-000000000000",
152165
resource_access=[
153-
ResourceAccess(id="e1fe6dd8-ba31-4d61-89e7-88639da4683d", type="Scope"),
166+
ResourceAccess(id=uuid.UUID("e1fe6dd8-ba31-4d61-89e7-88639da4683d"), type="Scope"),
154167
],
155168
),
156169
],
@@ -160,7 +173,7 @@ def client_app(server_app_id: str, server_app: Application, identifier: int) ->
160173
def server_app_known_client_application(client_app_id: str) -> Application:
161174
return Application(
162175
api=ApiApplication(
163-
known_client_applications=[client_app_id],
176+
known_client_applications=[uuid.UUID(f"{client_app_id}")],
164177
)
165178
)
166179

0 commit comments

Comments
 (0)