Permalink
Browse files

authentication

  • Loading branch information...
koush committed Feb 23, 2012
1 parent 92fa854 commit 52fc40b395f8080056140aeffcbf33c7a12f38ab
Showing with 23 additions and 0 deletions.
  1. +23 −0 authenticate.py
View
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+
+import sys
+import urllib2
+import urllib
+import os
+import json
+
+username = os.getenv('U')
+password = os.getenv('P')
+
+# will throw if it fails
+result = json.loads(urllib2.urlopen('https://github.com/api/v2/json/user/show/%s?login=%s&token=%s' % (username, username, password)).read())
+
+orgs = json.loads(urllib2.urlopen('https://github.com/api/v2/json/user/show/%s/organizations' % username).read())
+
+for org in orgs.get('organizations'):
+ if org.get('login') == 'CyanogenMod':
+ print "success"
+ sys.exit(0)
+
+print "not a member of org"
+sys.exit(1)

0 comments on commit 52fc40b

Please sign in to comment.