app.acquire_token_for_client error - AssertionError: Invalid parameter type #587
-
Getting Error while trying to acquire Token using below from msal import ConfidentialClientApplication #import secrets from keyvault app = ConfidentialClientApplication( Getting Error on this line , this was working fine until 21-Jul-2023 Please let me know what has changed in MSAL(PYPI) or what is the alternative with latest version If this can work with Previous Version let me know, which version to use Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 12 comments 2 replies
-
I think that the logic from this commit changed scope typing. |
Beta Was this translation helpful? Give feedback.
-
Out of curiosity, does your environment somehow always pull in the latest MSAL version, unknowingly? Most bug reports would pinpoint the differences as either "this was working until I upgrade to your new version X.Y.Z" or "this was working until I made a change in the code snippet" etc.. That being said, lucky that in this case, yes we can correlate the timing with our recent release of MSAL 1.23. Indeed, the following line works with MSAL 1.22 but can repro your error in MSAL 1.23.
We shall probably improve that exception message in the future. Meanwhile, as hinted by the line number in that exception, the error was about the scope input was meant to be a list, not a string. If at all possible, please change your By the way, is your app a long-lived daemon, or a one-time command-line tool? If it is the latter, you shall further consider to enable a token cache, otherwise your app risks being throttled if/when it sends out too much token requests. |
Beta Was this translation helpful? Give feedback.
-
had the same issue with release 1.23.0, was ok in 1.22.0 |
Beta Was this translation helpful? Give feedback.
-
Hi @rayluo - Thats correct, I always get latest version on MSAL, but after this error when I switched to v1.22, it seems to be working fine . I will try converting "scope" to ["scope"], and see if that works for me. [I am using Azure Databricks] Thanks |
Beta Was this translation helpful? Give feedback.
-
Myself and a colleague both have this issue at 2 different clients as of yesterday. My colleague noted just now that if you enclose the scopes value in brackets, seems to have resolved the issue for us. scopes must be expecting a list now? token = app.acquire_token_for_client(scopes=["https://database.windows.net/.default"])["access_token"] |
Beta Was this translation helpful? Give feedback.
-
The
Would you be able to ship your |
Beta Was this translation helpful? Give feedback.
-
Will the parameter stay a list now or will the change be reverted? |
Beta Was this translation helpful? Give feedback.
-
We both implemented the change in our respective code bases and have had no issues since. |
Beta Was this translation helpful? Give feedback.
-
The Even if we might bring back the "scopes as a string" usage, it will not be a revert. It will be with a DeprecationWarning. So, you are still recommended to switch to the list-of-string syntax, in order to be future proof. |
Beta Was this translation helpful? Give feedback.
-
Auto upgrades aside, it is evident that this change was not backwards-compatible, and introduced a breaking change. |
Beta Was this translation helpful? Give feedback.
-
To set the record straight, the concept of backwards-compatible or breaking-change does not apply to implementation details. In this case, the docs and the sample have all been a list of strings for 4 or 5 years. There is also the 2nd bullet point here saying that the undocumented behaviors are subject to change without prior notice. |
Beta Was this translation helpful? Give feedback.
-
I stand corrected; my apologies. |
Beta Was this translation helpful? Give feedback.
had the same issue with release 1.23.0, was ok in 1.22.0
I found that the 'scopes' parameter should be a list of strings.
as @rayluo said tried to wrap in []
eg.
s = ["https://graph.microsoft.com/.default"]