0

Im trying to log into an exchangeserver with the exchangelib. When I try to run the script it gives me an error: File "/usr/local/lib/python3.5/dist-packages/exchangelib/protocol.py", line 61, in init assert isinstance(credentials, Credentials) AssertionError

From what I can understand it says my credential variabel is not of the right type. I have tried both with and without autodiscover enabled. I get the same error. Here is the relevant code.

credents = Credentials(username='domain\\aaa.fh', password= 'password'), 

  config = Configuration(server='domain.aaa.no', credentials= credents)

  account = Account(
          primary_smtp_address='fh@domain.no',
          config=config,
          autodiscover=True,
          access_type=DELEGATE)
Lars Nordin
  • 2,785
  • 1
  • 22
  • 25

2 Answers2

0

Try this way:

config = Configuration(
                    server='mail.example.com',
                    credentials=Credentials(username='Domain\username', password='password'),
                    auth_type=NTLM
                    )
account = Account(primary_smtp_address='Emailaddress@domain.com', config=config,
                           access_type=DELEGATE)
Pravitha V
  • 3,308
  • 4
  • 33
  • 51
0

This is due to the dreaded Python trailing comma in the first line, which "helpfully" turns your credents variable into a tuple of Credentials.

Erik Cederstrand
  • 9,643
  • 8
  • 39
  • 63