yehoshuadimarsky / python-ssas

A proof of concept to integrate Python and Microsoft Analysis Services
MIT License
77 stars 33 forks source link

Error: Unable to obtain authentication #2

Closed anirmale closed 4 years ago

anirmale commented 4 years ago

I am getting following error while connecting to Azure server. My username and password are correct and I am able to connect to Azure manually from SSMS. However, unable to connect via this python code.

Can someone please let me know about resolution ?

code import ssas_api

conn = ssas_api.set_conn_string( ssas_server='', db_name='', username='', password='' )

dax_string = ''' EVALUATE CALCULATETABLE (LOBdd) ''' df = ssas_api.get_DAX(connection_string=conn, dax_string=dax_string) print ('df=' ,df)


error:

Microsoft.AnalysisServices.AdomdClient.NonInteractiveLoginException: Unable to obtain authentication token using the credentials provided. If your Active Directory tenant administrator has configured Multi-Factor Authentication or if your account is a Microsoft Account, please remove the user name and password from the connection string, and then retry. You should then be prompted to enter your credentials. at Microsoft.AnalysisServices.AdomdClient.AadAuthenticator.AcquireToken(String resource, String dataSource, String identityProvider, String tenantId, String userId, String password, Boolean useAdalCache, Boolean useAdTranslation) at Microsoft.AnalysisServices.AdomdClient.ConnectionInfo.ResolveHTTPConnectionPropertiesForPaaSInfrastructure(Uri& dataSourceUri, Boolean acquireAADToken, Boolean returnCloudConnectionAuthenticationProperties, String& paasCoreServerName, CloudConnectionAuthenticationProperties& cloudConnectionAuthenticationProperties) at Microsoft.AnalysisServices.AdomdClient.XmlaClient.OpenHttpConnection(ConnectionInfo connectionInfo, Boolean& isSessionTokenNeeded) at Microsoft.AnalysisServices.AdomdClient.XmlaClient.OpenConnection(ConnectionInfo connectionInfo, Boolean& isSessionTokenNeeded) at Microsoft.AnalysisServices.AdomdClient.XmlaClient.Connect(ConnectionInfo connectionInfo, Boolean beginSession) at Microsoft.AnalysisServices.AdomdClient.AdomdConnection.XmlaClientProvider.Connect(Boolean toIXMLA) at Microsoft.AnalysisServices.AdomdClient.AdomdConnection.ConnectToXMLA(Boolean createSession, Boolean isHTTP) at Microsoft.AnalysisServices.AdomdClient.AdomdConnection.Open() at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior) at Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)

yehoshuadimarsky commented 4 years ago

Are you using multi-factor authentication?

anirmale commented 4 years ago

Yes. It is an organizational account and it uses multifactor authentication (MFA) with Duo Mobile app. To make sure the error is due to MFA, I created a dummy account in Azure with sample tabular model. To this also I was not able to conect and got the same error even though it is not using MFA.

Is there any other way to authenticate from python code ?

yehoshuadimarsky commented 4 years ago

I don't know. This is not a Python issue, it's a matter of finding the correct .Net API call to use to login with MFA. Python is simply a wrapper around it using Pythonnet.

anirmale commented 4 years ago

For below code , now I am getting "Conn=None" . Can you please let me know how the "Conn= " string looks like ?

conn = ssas_api.set_conn_string( ssas_server='', db_name='', username='', password='' )

print ('conn=' ,conn)

conn= None