Zimbra-Community / python-zimbra

Core framework for easily sending requests to the Zimbra SOAP-API
BSD 2-Clause "Simplified" License
63 stars 26 forks source link

permission denied: need adequate admin token #27

Closed sjkcdpc closed 4 years ago

sjkcdpc commented 4 years ago

Generate token according to https://wiki.zimbra.com/wiki/Preauth article version:zcs-8.8.15_GA_3869.RHEL7_64.20190918004220

user_list.py

from pythonzimbra.communication import Communication from pythonzimbra.tools import auth

url = 'https://mail.xxx.com:7071/service/admin/soap' comm = Communication(url)

user_token = auth.authenticate( url, 'admin@xxx.com', 'xxx' ) info_request = comm.gen_request(token=user_token) info_request.add_request( 'GetAccountRequest', {}, 'urn:zimbraAdmin' )

info_response = comm.send_request(info_request) info_response.response_type = 'json' if not info_response.is_fault(): print(info_response.get_response()['GetFolderResponse']) else: print(info_response.get_fault_message())

$ python user_list.py permission denied: need adequate admin token

R13e commented 4 years ago

as described in README.md

Zimbra currently doesn't support the preauth-method for authentications against the admin-console (URL https://your-zimbra-server:7071/service/admin/soap).

barrydegraaff commented 4 years ago

To get an admin auth token in an easy way, log in to the admin console with Google chrome, then hit F12 then go to the Network Tab, reload the screen if needed and in the cookies tab, copy paste the admin auth token.