I have the following:
@auth.verify_password
def verify_password(username_or_token, password):
logger = logging.getLogger('__name__')
logger.error('username = %s' %username_or_token)
# first try to authenticate by token
user = USER.verify_auth_token(username_or_token)
if not user:
with contextlib.closing(DBSession()) as session:
try:
# try to authenticate with username/password
user = session.query(USER).filter_by(USERSEMAIL = username_or_token).first()
if not user or not user.verify_password(password):
return False
except exc.SQLAlchemyError, error:
session.rollback()
raise_database_error(error)
g.user = user
return True
@app.route('/api/token')
@auth.login_required
def get_auth_token():
token = g.user.generate_auth_token()
return jsonify({ 'token': token.decode('ascii') })
When I access the api/token
route using localhost
, I am prompted to enter my username
and password
. Afterwards when I check my log, I find that the username_or_token
variable is ''
.
The strange this is I have tested the exact same code on my online server
and had no issues..
I am using Advanced Rest Client
. When using this plugin
, I add an Authorisation header
and use the drop down fields Login
and Password
under the Basic
tab. I have been doing the same when executing on my online server
.
I am using XAMPP
. Not really too sure what other info to provide.
Has anyone ever experienced this before?
Request Details
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36
Authorization: Basic Z2lyaTFAZ21haWwuY29tOmFzZA==
Accept: */*
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8,zh-CN;q=0.6,zh-TW;q=0.4
HTTPIE Output
Once again the username
is set to ''
.