Acquire Azure AD token with username & password using python MSAL

Mohammed Sohail 61 Reputation points

Getting Error
ValueError: Unsupported soap action: None. Contact your administrator to check your ADFS's MEX settings. when trying to acquire token from Azure Active Directory using MSAL

The following is the snippet used to get token

scope = ['']
authority_url = '' + tenant_id

import msal
app = msal.ConfidentialClientApplication(client_id=client_id,authority=authority_url)
msal_token = app.acquire_token_by_username_password(username='xxxxxx@xxxxxx .com',password='xxxxxxxx', scopes=scope)

Azure Active Directory
Azure Active Directory
An Azure enterprise identity service that provides single sign-on and multi-factor authentication.
14,892 questions
Active Directory Federation Services
Active Directory Federation Services
An Active Directory technology that provides single-sign-on functionality by securely sharing digital identity and entitlement rights across security and enterprise boundaries.
1,038 questions
{count} votes

Accepted answer
  1. Shweta Mathur 15,071 Reputation points Microsoft Employee

    Hi @Mohammed Sohail ,

    Thanks for reaching out.

    I understand you are trying to get access token through Resource Owner Password Credential (ROPC) flow using Confidential client application class but getting the error.

    I have never come across this error before. Are you migrating your application from ADAL to MSAL?

    But based on the snippet you mentioned, you are using confident client with ROPC flow which is technically supported but not by any of the official SDK's.

    If you wish to use the confidential client, then it must be included the client_secret which is missing in above snippet and scope should be passed as space separated list of permissions.

    Sample code using public client application with ROPC flow:

    ROPC flow with required parameters:

    Hope this will help.



    Please remember to "Accept Answer" if answer helped you.

0 additional answers

Sort by: Most helpful