def get_token(): if g.current_user.is_anonymous() or g.token_used: return unauthorized('Invalid credentials') return jsonify({ 'token': g.current_user.generate_auth_token(expiration=3600), 'expiration': 3600 })
def oauth_callback(provider): # rand_pass will be a new password every time a user logs in # with oauth. temp_pass = str(uuid.uuid4()) # lets create the oauth object that will issue the request. oauth = OAuthSignIn.get_provider(provider) # assign the response email, first_name, last_name = oauth.callback() if email is None: return unauthorized('Invalid credentials') # see if this user already exists, and # and give the user a brand new password. user = User.query.filter_by(email=email).first() if user: user.password = temp_pass # if there is no user, create a new one and setup # it's defaults and give it a new password. else: user = User.insert_user(password=temp_pass, username=email, email=email, first_name=first_name, last_name=last_name) return jsonify({'uuid': temp_pass, 'username': email})
def auth_error(): return unauthorized('Invalid credentials')
def get_token(): print 'getting token' if g.current_user.is_anonymous or g.token_used: return unauthorized('Invalid credentials') return jsonify({'token': g.current_user.generate_auth_token( expiration=86400), 'expiration': 86400}) # 24 hours