Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion msal/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,12 @@ def _acquire_token_interactive(app, scopes=None, data=None):
return result

def _acquire_token_by_username_password(app):
"""acquire_token_by_username_password() - See constraints here: https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-authentication-flows#constraints-for-ropc"""
"""
[Deprecated] This API is deprecated for PublicClientApplication(PCA) flows and will be removed in a future release. Use a more secure flow instead.
Migration guide: https://aka.ms/msal-ropc-migration

acquire_token_by_username_password() - See constraints here: https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-authentication-flows#constraints-for-ropc
"""
print_json(app.acquire_token_by_username_password(
_input("username: "), getpass.getpass("password: "), scopes=_input_scopes()))

Expand Down
11 changes: 10 additions & 1 deletion msal/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -1815,7 +1815,11 @@ def acquire_token_by_username_password(
# because this ROPC won't work with MSA account anyway.
auth_scheme=None,
**kwargs):
"""Gets a token for a given resource via user credentials.
"""
[Deprecated] This API is deprecated for PublicClientApplication(PCA) flows and will be removed in a future release. Use a more secure flow instead.
Migration guide: https://aka.ms/msal-ropc-migration

Gets a token for a given resource via user credentials.

See this page for constraints of Username Password Flow.
https://github.com/AzureAD/microsoft-authentication-library-for-python/wiki/Username-Password-Authentication
Expand All @@ -1841,6 +1845,11 @@ def acquire_token_by_username_password(
- A successful response would contain "access_token" key,
- an error response would contain "error" and usually "error_description".
"""
is_confidential_app = self.client_credential or isinstance(
self, ConfidentialClientApplication)
if not is_confidential_app:
warnings.warn("This API has been deprecated for public client flows, please use a more secure flow. " \
"See https://aka.ms/msal-ropc-migration for migration guidance", DeprecationWarning)
claims = _merge_claims_challenge_and_capabilities(
self._client_capabilities, claims_challenge)
if self._enable_broker and sys.platform in ("win32", "darwin"):
Expand Down
Loading