Repository navigation
Description
Hello!
Trying to make any .get() call from my GraphServiceClient results in the following error:
ValueError
Traceback (most recent call last)
1 # GET /users?$top=500
2 #users = await client.users.by_user_id('cjusko').get()
----> 3 users = await client.users.get()
4 print(users.value)
File ~/.local/share/hatch/env/virtual/hat/hYHKRVU-/that/lib/python3.11/site-packages/msgraph/generated/users/users_request_builder.py:69, in UsersRequestBuilder.get(self, request_configuration)
66 raise Exception("Http core is null")
67 from ..models.user_collection_response import UserCollectionResponse
---> 69 return await self.request_adapter.send_async(request_info, UserCollectionResponse, error_mapping)
File ~/.local/share/hatch/env/virtual/hat/hYHKRVU-/that/lib/python3.11/site-packages/kiota_http/httpx_request_adapter.py:178, in HttpxRequestAdapter.send_async(self, request_info, parsable_factory, error_map)
175 parent_span.record_exception(REQUEST_IS_NULL)
176 raise REQUEST_IS_NULL
--> 178 response = await self.get_http_response_message(request_info, parent_span)
180 response_handler = self.get_response_handler(request_info)
181 if response_handler:
File ~/.local/share/hatch/env/virtual/hat/hYHKRVU-/that/lib/python3.11/site-packages/kiota_http/httpx_request_adapter.py:543, in HttpxRequestAdapter.get_http_response_message(self, request_info, parent_span, claims)
541 parent_span.set_attribute("http.response_content_type", content_type)
542 _get_http_resp_span.end()
--> 543 return await self.retry_cae_response_if_required(resp, request_info, claims)
File ~/.local/share/hatch/env/virtual/that/hYHKRVU-/hat/lib/python3.11/site-packages/kiota_http/httpx_request_adapter.py:560, in HttpxRequestAdapter.retry_cae_response_if_required(self, resp, request_info, claims)
558 claims_match = re.search('claims="(.+)"', auth_header_value)
559 if not claims_match:
--> 560 raise ValueError("Unable to parse claims from response")
561 response_claims = claims_match.group().split('="')[1]
562 parent_span.add_event(AUTHENTICATE_CHALLENGED_EVENT_KEY)
ValueError: Unable to parse claims from response
Some context:
This is in virtalenv running
python==3.11.6
and
msgraph-sdk==1.2.0 (but I received the same error on version 1.3.0 as well, tried downgrading to see if it resolved, it did not)
the code I'm running is fairly simple:
from azure.identity import AzureAuthorityHosts
from azure.identity.aio import ClientSecretCredential
from msgraph import GraphServiceClient
auth = {
# DICT holding 'tenant ID', 'client ID', 'client secret key'
}
credential = ClientSecretCredential(
auth['tenant'],
auth['clientId'],
auth['clientSecret'],
authority=AzureAuthorityHosts.AZURE_GOVERNMENT
)
scopes = ['https://graph.microsoft.us/.default']
client = GraphServiceClient(credentials=credential, scopes=scopes)
users = await client.users.get() # <--- Error on this line
I am running this in a jupyter notebook, but running in IPython leads to same result. Same result when running in a script and calling like this as well:
async def get_user():
users = await client.users.get() # <--- Error on this line
# ...
asyncio.run(get_user())
I'm guessing it's likely an issue with my client setup since I can't seem to find anyone else having this issue. But not sure how else to set it up, I can confirm that my tenant and client information is correct. Maybe it's an issue in how I have it set up to hit AZURE_GOVERNMENT?
Thanks in advance!
Activity
shemogumbe commentedon Apr 22, 2024
Hello, to be able to understand the issue,
I see you are trying to get a list of users, there is a possibility that:
My suggestions
Note
Kindly counter check the equivalent scope for get users in the government cloud, trying to reproduce your issue got me the error unable to process claims response when using the scope ``
but worked fine with default authority, and default scope in public cloud:
No error here:
Having only replaced
scopes = ['https://graph.microsoft.us/.default']withscopes = ['https://graph.microsoft.com/.default']and
authority=AzureAuthorityHosts.AZURE_GOVERNMENTwithauthority='https://login.microsoftonline.com/common'cjusko commentedon Apr 24, 2024
making these changes gives back a different error:
ClientSecretCredential.get_token failed: argument of type 'NoneType' is not iterableWith this code:
Here's the full traceback:
deanevs commentedon May 1, 2024
I have the exact same issue, the adapter always get's set to the host: graph.microsoft.com even though the authority is set up with a token for US_GOV??
Setup ->
Debug ->
Error ->
deanevs commentedon May 2, 2024
Worked it out, you need to set the adapter base_url before passing it to the GraphServiceClient
shemogumbe commentedon May 21, 2024
Moving these two discussions as it may help someone facing a similar issue
isiahzzzz commentedon Jun 18, 2024
I'm running into this same exact issue.
Python version
3.12.3, msgraphsdk version1.4.0.I have a
Graphclass that sets up my GraphServiceClient, I'm also using Application Authentication vs Delegated Auth. This class has atest()method for getting a list of users, and aget_app_only_token()method used to see if I'm getting back an access token, which I am.The class:
Traceback:
I've tried what Dean Evans (@deanevs) recommended but no dice, any advice would be super. Thanks in advance.
zhetao1116 commentedon Sep 16, 2024
Hi Shem Ogumbe (@shemogumbe) ! I am facing the same issue although I am invoking the public API and it happens when the token is invalid or expired.
I also tried Dean Evans (@deanevs) approach but it doesn't work unfortunatedly. Any idea how could I fix it to get the error response?