{KeyVault} Replace _token_retriever with get_raw_token#17812
Merged
{KeyVault} Replace _token_retriever with get_raw_token#17812
_token_retriever with get_raw_token#17812Conversation
jiasli
commented
Apr 22, 2021
Comment on lines
10
to
+11
| def _get_token(cli_ctx, server, resource, scope): # pylint: disable=unused-argument | ||
| return Profile(cli_ctx=cli_ctx).get_login_credentials(resource)[0]._token_retriever() # pylint: disable=protected-access | ||
| return Profile(cli_ctx=cli_ctx).get_raw_token(resource)[0] |
Member
Author
There was a problem hiding this comment.
This _get_token never works because it doesn't comply with KeyVaultAuthentication's authorization_callback signature.
Also defer to @houk-ms to fix it in the future.
Member
|
How about put |
4 tasks
qwordy
reviewed
Apr 22, 2021
|
|
||
| def get_token(server, resource, scope): # pylint: disable=unused-argument | ||
| return Profile(cli_ctx=cli_ctx).get_login_credentials(resource)[0]._token_retriever() # pylint: disable=protected-access | ||
| return Profile(cli_ctx=cli_ctx).get_raw_token(resource)[0] |
Member
There was a problem hiding this comment.
Can we make Profile object a global singleton?
Member
Author
There was a problem hiding this comment.
Good suggestion. Will consider doing that in the future.
Contributor
We will consider to do that when KeyVault data-plane SDK decides to migrate to Track2. Before that, i prefer we keep the original implementation for simplicity. |
houk-ms
approved these changes
Apr 22, 2021
qwordy
approved these changes
Apr 22, 2021
evelyn-ys
approved these changes
Apr 22, 2021
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split from #17738
Description
As pointed out by #15854, calling the protected method
_token_retrieveris simply wrong.This PR replaces
_token_retrieverwithazure.cli.core._profile.Profile.get_raw_token, as provided by #15805 (comment).This is also the approach adopted by
azure.cli.command_modules.keyvault._client_factory.keyvault_data_plane_factory:azure-cli/src/azure-cli/azure/cli/command_modules/keyvault/_client_factory.py
Lines 128 to 137 in 1eed077
On the other hand, instead of implementing its own keyvault client factory, appconfig directly uses
azure.cli.command_modules.keyvault._client_factory.keyvault_data_plane_factory(#15826):azure-cli/src/azure-cli/azure/cli/command_modules/appconfig/_kv_helpers.py
Lines 300 to 301 in 7a5538f
Other command modules may follow the same approach, but I will defer this decision to @houk-ms.