def facebook_authorized(resp): if resp is None: return 'Access denied: reason=%s error=%s' % ( request.args['error_reason'], request.args['error_description'] ) session['oauth_token'] = (resp['access_token'], '') me = facebook.get('/me') if checkEmail(me.data['email'])== False : url = "http://graph.facebook.com/"+ me.data['location']['id'] result = urllib2.urlopen(url).read() result = json.loads(result) addUser(me.data['id'],me.data['username'], me.data['email'], 'abcde',me.data['location']['name'],resp['access_token'],"facebook",str(result['location']['longitude']),str(result['location']['latitude'])) session['email'] = me.data['email'] return redirect(url_for('profile')) else: if userType(me.data['email']) == "facebook": session['email'] = me.data['email'] return redirect(url_for('profile')) else: form = SigninForm() form.email.errors = ["Wrong Account Type"] return render_template('signin.html', form=form)
def facebook_authorized(resp): if resp is None: return 'Access denied: reason=%s error=%s' % ( request.args['error_reason'], request.args['error_description']) session['oauth_token'] = (resp['access_token'], '') me = facebook.get('/me') if checkEmail(me.data['email']) == False: url = "http://graph.facebook.com/" + me.data['location']['id'] result = urllib2.urlopen(url).read() result = json.loads(result) addUser(me.data['id'], me.data['username'], me.data['email'], 'abcde', me.data['location']['name'], resp['access_token'], "facebook", str(result['location']['longitude']), str(result['location']['latitude'])) session['email'] = me.data['email'] return redirect(url_for('profile')) else: if userType(me.data['email']) == "facebook": session['email'] = me.data['email'] return redirect(url_for('profile')) else: form = SigninForm() form.email.errors = ["Wrong Account Type"] return render_template('signin.html', form=form)
res = urlopen(req) except URLError, e: if e.code == 401: # Unauthorized - bad token session.pop('access_token', None) return redirect(url_for('glogin')) res = json.load(res) if checkEmail(res['email'])== False : addUser(res['id'],res['name'],res['email'],"123",None, access_token , "google",None, None) session['email'] = res['email'] return redirect(url_for('profile')) else: if userType(res['email']) == "google": session['email'] = res['email'] return redirect(url_for('profile')) else: form = SigninForm() form.email.errors = ["Wrong Account Type"] return render_template('signin.html', form=form) @google.tokengetter def get_access_token(): return session.get('access_token') #------------------------------------------------------------------------
except URLError, e: if e.code == 401: # Unauthorized - bad token session.pop('access_token', None) return redirect(url_for('glogin')) res = json.load(res) if checkEmail(res['email']) == False: addUser(res['id'], res['name'], res['email'], "123", None, access_token, "google", None, None) session['email'] = res['email'] return redirect(url_for('profile')) else: if userType(res['email']) == "google": session['email'] = res['email'] return redirect(url_for('profile')) else: form = SigninForm() form.email.errors = ["Wrong Account Type"] return render_template('signin.html', form=form) @google.tokengetter def get_access_token(): return session.get('access_token') #------------------------------------------------------------------------