def login(self, args): code = args.get('code') # get access_token log.debug(get_config('login.weibo.access_token_url') + code) token_resp = post_to_remote(get_config('login.weibo.access_token_url') + code, {}) log.debug("get token from Weibo:" + str(token_resp)) access_token = token_resp['access_token'] uid = token_resp['uid'] log.debug("get token info from weibo") data = {"provider": "weibo", "code": code, "access_token": access_token, "uid": uid, "hackathon_name": hackathon_name} return post_to_remote('%s/api/user/login' % hackathon_api_url, data)
def login(self, args): code = args.get('code') # get access_token log.debug(get_config('login.weibo.access_token_url') + code) token_resp = post_to_remote( get_config('login.weibo.access_token_url') + code, {}) log.debug("get token from Weibo:" + str(token_resp)) access_token = token_resp['access_token'] uid = token_resp['uid'] log.debug("get token info from weibo") data = { "provider": "weibo", "code": code, "access_token": access_token, "uid": uid, "hackathon_name": hackathon_name } return post_to_remote('%s/api/user/login' % hackathon_api_url, data)
def login(self, args): code = args.get('code') url = get_config('login.gitcafe.access_token_url') + code opener = urllib2.build_opener(urllib2.HTTPHandler) request = urllib2.Request(url, "") # req = requests.post(url, verify=True) resp = opener.open(request) # log.debug("get token from gitcafe:" + resp.read()) token_resp = json.loads(resp.read()) # token_resp = json.loads(resp.read()) # token_resp = req.content() data = {"provider": "gitcafe", "access_token": token_resp['access_token'], "hackathon_name": hackathon_name} return post_to_remote('%s/api/user/login' % hackathon_api_url, data)
def login(self, args): code = args.get('code') # get access_token token_resp = get_remote(get_config('login.github.access_token_url') + code) log.debug("get token from github:" + token_resp) start = token_resp.index('=') end = token_resp.index('&') access_token = token_resp[start + 1:end] # get user info # user_info_resp = get_remote(get_config('login/github/user_info_url') + access_token) # conn.request('GET',url,'',{'user-agent':'flask'}) log.debug("get token info from github") data = {"provider": "github", "code": code, "access_token": access_token, "hackathon_name": hackathon_name} return post_to_remote('%s/api/user/login' % hackathon_api_url, data)
def login(self, args): code = args.get('code') state = "openhackathon" # if state != QQ_OAUTH_STATE: # log.warn("STATE match fail. Potentially CSFR.") # return "UnAuthorized", 401 # get access token token_resp = get_remote(get_config("login.qq.access_token_url") + code + '&state=' + state) log.debug("get token from qq:" + token_resp) start = token_resp.index('=') end = token_resp.index('&') access_token = token_resp[start + 1:end] # get user info data = {"provider": "qq", "access_token": access_token} # url = get_config("login/qq/user_info_url") % (access_token, client_id, openid) return post_to_remote('%s/api/user/login' % hackathon_api_url, data)
def login(self, args): code = args.get('code') url = get_config('login.gitcafe.access_token_url') + code opener = urllib2.build_opener(urllib2.HTTPHandler) request = urllib2.Request(url, "") # req = requests.post(url, verify=True) resp = opener.open(request) # log.debug("get token from gitcafe:" + resp.read()) token_resp = json.loads(resp.read()) # token_resp = json.loads(resp.read()) # token_resp = req.content() data = { "provider": "gitcafe", "access_token": token_resp['access_token'], "hackathon_name": hackathon_name } return post_to_remote('%s/api/user/login' % hackathon_api_url, data)
def login(self, args): code = args.get('code') # get access_token token_resp = get_remote( get_config('login.github.access_token_url') + code) log.debug("get token from github:" + token_resp) start = token_resp.index('=') end = token_resp.index('&') access_token = token_resp[start + 1:end] # get user info # user_info_resp = get_remote(get_config('login/github/user_info_url') + access_token) # conn.request('GET',url,'',{'user-agent':'flask'}) log.debug("get token info from github") data = { "provider": "github", "code": code, "access_token": access_token, "hackathon_name": hackathon_name } return post_to_remote('%s/api/user/login' % hackathon_api_url, data)
def login(self, args): code = args.get('code') state = "openhackathon" # if state != QQ_OAUTH_STATE: # log.warn("STATE match fail. Potentially CSFR.") # return "UnAuthorized", 401 # get access token token_resp = get_remote( get_config("login.qq.access_token_url") + code + '&state=' + state) log.debug("get token from qq:" + token_resp) start = token_resp.index('=') end = token_resp.index('&') access_token = token_resp[start + 1:end] # get user info data = { "provider": "qq", "access_token": access_token, "hackathon_name": hackathon_name } # url = get_config("login/qq/user_info_url") % (access_token, client_id, openid) return post_to_remote('%s/api/user/login' % hackathon_api_url, data)
def post_to_api_service(path, post_data, hackathon_id): return post_to_remote(__get_uri(path), post_data, headers=__get_headers(hackathon_id))