Skip to content

Commit

Permalink
Fix Grafana lookup auth header for py2/3 compatibility (ansible#50816)
Browse files Browse the repository at this point in the history
  • Loading branch information
markchalloner authored and Akasurde committed Nov 18, 2019
1 parent a3c0277 commit 13a8dbf
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/ansible/plugins/lookup/grafana_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
import os
from ansible.errors import AnsibleError, AnsibleParserError
from ansible.plugins.lookup import LookupBase
from ansible.module_utils.urls import open_url
from ansible.module_utils.urls import basic_auth_header, open_url
from ansible.module_utils._text import to_bytes, to_native
from ansible.module_utils.six.moves.urllib.error import HTTPError
from ansible.utils.display import Display
Expand Down Expand Up @@ -124,8 +124,7 @@ def grafana_headers(self):
if self.grafana_api_key:
headers['Authorization'] = "Bearer %s==" % self.grafana_api_key
else:
auth = base64.b64encode(to_bytes('%s:%s' % (self.grafana_user, self.grafana_password)).replace('\n', ''))
headers['Authorization'] = 'Basic %s' % auth
headers['Authorization'] = basic_auth_header(self.grafana_user, self.grafana_password)
self.grafana_switch_organisation(headers)

return headers
Expand Down

0 comments on commit 13a8dbf

Please sign in to comment.