Created
June 28, 2013 17:46
-
-
Save netscruff/5886593 to your computer and use it in GitHub Desktop.
Workaround for foundation api auth-v1 urls
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import argparse | |
| import getpass | |
| import urllib | |
| import urllib2 | |
| import base64 | |
| parser = argparse.ArgumentParser(description='Authentication test using foundation api.') | |
| parser.add_argument('-u', dest='userid', type=str, | |
| help='Your iPlant userid') | |
| args = parser.parse_args() | |
| userid = args.userid | |
| password = getpass.getpass() | |
| url = "https://foundation.iplantc.org/auth-v1/" | |
| req = urllib2.Request(url) | |
| base64string = base64.encodestring('%s:%s' % (userid, password)).replace('\n', '') | |
| req.add_header("Authorization", "Basic %s" % base64string) | |
| print(req.get_method()) | |
| result = urllib2.urlopen(req) | |
| print(result.read()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment