summaryrefslogtreecommitdiff
path: root/notification
diff options
context:
space:
mode:
authorToshio Kuratomi <toshio@fedoraproject.org>2015-07-28 11:35:58 -0700
committerToshio Kuratomi <toshio@fedoraproject.org>2015-07-28 11:36:31 -0700
commit0297a7e7e67c43e545b001b1499321d4849a7799 (patch)
tree5f135a69ce066a2f45f01e3be477e3bec044660f /notification
parente30d8b84fe7ff3be427a46ff67629cce55252594 (diff)
downloadansible-modules-extras-0297a7e7e67c43e545b001b1499321d4849a7799.tar.gz
Use fetch_urls code to do basic auth instead of our own i nthe twilio
module
Diffstat (limited to 'notification')
-rw-r--r--notification/twilio.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/notification/twilio.py b/notification/twilio.py
index 58898b0b..9ed1a09e 100644
--- a/notification/twilio.py
+++ b/notification/twilio.py
@@ -104,7 +104,6 @@ EXAMPLES = '''
# =======================================
# twilio module support methods
#
-import base64
import urllib
@@ -119,14 +118,15 @@ def post_twilio_api(module, account_sid, auth_token, msg, from_number,
data['MediaUrl'] = media_url
encoded_data = urllib.urlencode(data)
- base64string = base64.encodestring('%s:%s' % \
- (account_sid, auth_token)).replace('\n', '')
-
headers = {'User-Agent': AGENT,
'Content-type': 'application/x-www-form-urlencoded',
'Accept': 'application/json',
- 'Authorization': 'Basic %s' % base64string,
}
+
+ # Hack module params to have the Basic auth params that fetch_url expects
+ module.params['url_username'] = account_sid.replace('\n', '')
+ module.params['url_password'] = auth_token.replace('\n', '')
+
return fetch_url(module, URI, data=encoded_data, headers=headers)