-
Notifications
You must be signed in to change notification settings - Fork 24
Closed
Description
Hi all,
one of my CI jobs checking user status in azure started failing yesterday following upgrade of the kiota python packages.
I've pinned it back down to 1.9.0 so am not stuck but I'd like to know if I am doing something wrong in my script.
Environement:
- Linux and Mac.
- Python 3.12.5
-- microsoft-kiota-abstractions==1.9.1
-- microsoft-kiota-authentication-azure==1.9.1
-- microsoft-kiota-http==1.9.1
-- microsoft-kiota-serialization-form==1.9.1
-- microsoft-kiota-serialization-json==1.9.1
-- microsoft-kiota-serialization-multipart==1.9.1
-- microsoft-kiota-serialization-text==1.9.1
-- msgraph-core==1.1.2
-- msgraph-sdk==1.5.4
-- urllib3==2.2.2
Traceback (most recent call last):
File "/Users/clecoz/work/cmf_lib/cmflib_main/cmflib/test_kiota.py", line 52, in <module>
asyncio.run(_get_user_status('clecoz'))
File "/Users/clecoz/.pyenv/versions/3.12.8/lib/python3.12/asyncio/runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/Users/clecoz/.pyenv/versions/3.12.8/lib/python3.12/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/clecoz/.pyenv/versions/3.12.8/lib/python3.12/asyncio/base_events.py", line 686, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/Users/clecoz/work/cmf_lib/cmflib_main/cmflib/test_kiota.py", line 38, in _get_user_status
response = await client.users.get(request_configuration=request_configuration)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/clecoz/.pyenv/versions/ldap_3.12.8/lib/python3.12/site-packages/msgraph/generated/users/users_request_builder.py", line 72, in get
return await self.request_adapter.send_async(request_info, UserCollectionResponse, error_mapping)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/clecoz/.pyenv/versions/ldap_3.12.8/lib/python3.12/site-packages/kiota_http/httpx_request_adapter.py", line 186, in send_async
response = await self.get_http_response_message(request_info, parent_span)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/clecoz/.pyenv/versions/ldap_3.12.8/lib/python3.12/site-packages/kiota_http/httpx_request_adapter.py", line 595, in get_http_response_message
await self._authentication_provider.authenticate_request(
File "/Users/clecoz/.pyenv/versions/ldap_3.12.8/lib/python3.12/site-packages/kiota_abstractions/authentication/base_bearer_token_authentication_provider.py", line 50, in authenticate_request
token = await self.access_token_provider.get_authorization_token(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/clecoz/.pyenv/versions/ldap_3.12.8/lib/python3.12/site-packages/kiota_authentication_azure/azure_identity_access_token_provider.py", line 78, in get_authorization_token
raise exc
kiota_authentication_azure._exceptions.HTTPError: Valid url scheme and host required
Quick test script I wrote to investigate: following works with 1.9.0 but give above error with 1.9.1
#!/usr/bin/env python3
import asyncio
from msgraph import GraphServiceClient
from msgraph.generated.users.users_request_builder import UsersRequestBuilder
from msgraph.generated.groups.groups_request_builder import GroupsRequestBuilder
from azure.identity.aio import ClientSecretCredential
DEFAULT_GRAPH = 'https://graph.microsoft.com/.default'
DEFAULT_TENANT = 'tenant_redacted'
username='uname_redacted'
password='password_redacted'
credentials = ClientSecretCredential(DEFAULT_TENANT, username, password)
scopes=[DEFAULT_GRAPH]
client = GraphServiceClient(credentials=credentials, scopes=scopes)
async def _get_user_status(userid:str) -> dict:
query_params = UsersRequestBuilder.UsersRequestBuilderGetQueryParameters(
search=[
f'("displayName:{userid}" OR "mail:{userid}" OR "userPrincipalName:{userid}"\
OR "givenName:{userid}" OR "surName:{userid}" OR "otherMails:{userid}")'
],
filter="accountEnabled eq true",
)
request_configuration = (
UsersRequestBuilder.UsersRequestBuilderGetRequestConfiguration(
query_parameters=query_params,
)
)
request_configuration.headers.add("ConsistencyLevel", "eventual")
response = await client.users.get(request_configuration=request_configuration)
if response.value:
user = response.value[0]
print(f"{userid} found in AD. Principal: {user.user_principal_name}, "
f"Id: {user.id}, Display: {user.display_name}")
return {
"display": user.display_name,
"mail": user.mail,
"id": user.id,
"principal": user.user_principal_name
}
print(f"{userid} not found in AD")
asyncio.run(_get_user_status('clecoz'))
Thanks,
Cedric.
Mrfence97, adam-blanchard, Julian-J-S and EdytaSuska
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Done ✔️