-
Tried running with curl and it works:
curl -u admin:admin [email protected] -H "Content-Type:application/json" http://localhost:6610/~api/settings/mail-service -
Hmmm... After tweaking and testing some more, I think there is an error in the Ansible
uricomponent and how it handles HTTP Basic auth. This works:- name: Configure SMTP Server ansible.builtin.uri: url: "http://{{ onedev_ip }}:6610/~api/settings/mail-service" # user: "{{ onedev.admin.username }}" # password: "{{ onedev.admin.password }}" headers: "Authorization": "Basic {{ (onedev.admin.username + ':' + onedev.admin.password) | b64encode }}" # "Content-Type": "application/json" method: POST body: "@type": "SmtpImapConnector" smtpHost: "{{ onedev.smtp.host }}" smtpUser: "{{ onedev.smtp.user }}" smtpPassword: "{{ onedev.smtp.password }}" systemAddress: "{{ onedev.smtp.from }}" inboxPollSetting: null body_format: json # body: "{{ lookup('ansible.builtin.template', 'email.json.j2') }}" # force_basic_auth: true status_code: [200, 201, 202] tags: - onedevNotice that I had to build my own
Authorization: BASICheader instead of using the user/pass options from the ansible module. Strange! I will open an issue in the appropriate ansible repo! -
Seems that the problem is in Ansible and not OneDev! Thanks @robin
-
Previous Value Current Value Open
Closed
| Type |
Question
|
| Priority |
Normal
|
| Assignee | |
| Labels |
No labels
|
Issue Votes (0)
Hello again. Trying to configure the
SmtpImapConnectorusing the REST API and getting a 401 Unauthorized.I have confirmed that the username/password works for logging on to the Web UI and has Admin privileges.
Ansible Task:
And the JSON Template:
Which results in: