Unity POST request to local host - python

Soooooo, I've checked every answer I can on this site. But I'm not finding a solution that is working. I'm trying to log a user into a site I am developing on local host from a unity application. I'm not passing the boolean "remember" because it was giving me issues.
My unity code is:
IEnumerator Login(string username, string password, bool remember)
{
List<IMultipartFormSection> formData = new List<IMultipartFormSection>();
formData.Add(new MultipartFormDataSection("username=" + username + "&password=" + password));
using (UnityWebRequest www = UnityWebRequest.Post("http://127.0.0.1:5000/api/children/mobile_login/", formData))
{
yield return www.SendWebRequest();
var response = www.downloadHandler.text;
Debug.Log(response);
if (www.isNetworkError || www.isHttpError)
{
Debug.Log(www.error);
}
else
{
Debug.Log("Login complete!");
}
}
}
and my python code is:
#children.route('/mobile_login', methods=['POST'])
def mobile_login():
username = request.form.get('username')
password = request.form.get('password')
remember = request.form.get('remember')
user = User.objects(username=username).first()
if user and crypt.check_password_hash(user.password, password):
login_user(user)
user.save()
token = user.get_auth_token()
res = make_response(jsonify({"user": user}), 200)
if remember:
res.set_cookie('child-auth', value=token, path='/')
return res
else:
return jsonify({"error": "unable to login"}), 401
The code is returning "{"error": "unable to login"}" and HTTP/1.1 401 Unauthorized.
I know for a fact that the username and password are correct. And I know the log in function works because my colleague is able to login from the react app he is working on.
I tried running my local host as https but that didn't work so I changed it back to http.
Any suggestions?

Related

how to I find if the password request I sent was incorrect

I am sending a request with the python requests module. I am sending a password to a google account and I am trying to test if the password is correct. What Im trying to do is send a request to a google account (specifically the password) and see if it is incorrect or correct. Something like this
import requests
url = "https://accounts.google.com/_/signin/challenge?hl=en&TL=AM3QAYYAJTV2Rk9VLpHkVyzIm_dvd2rfL_iesxv3mdEp8ROzj4dS7-stAZLHA5jH&_reqid=147299&rt=j"
data = {
"ifkv": "AU9NCcyDvQcP7mxMnmcRIr8sQgZ1sjYwtVz619gM17KuLjEb-PXDkhudvXPh-0lHSUaeFZFYOaaLDg",
"continue": "https://www.google.com/?hl=en-US&authuser=2",
"hl": "en",
"f.req": '["AEThLlzBETPgqvfWZqupcOZCCZjboZRguZI4FLwrnyOXtjR7Vxl3zsK0_xoeP3sZCJjbXUirN4jesiR-aCZGK2ibIP_LWcU_NDyt5cPpiBg6KdWRew2A3tl1xPcam-imC5DsVInnD54kZ6lY6bK02M-LGo0YD8s-AbmqDg78GU8yt661DYQkH90Yp4Q2dEp91QaxUH0NEkr1y1zTYbN_oQzpmqkeGoinQt-QhRcXQEJxjQdb4ft-m2g3xCFs1VERtMt98hpKQiR00ytBfVhjIKmzQiTbDLSzfhY6sNrYdqZtuxixnKtXLb3nYvoYY9NhkY0SRp8XVKF6rInCtfCrzZd9wlMgY1Yn8Uek25_wNLotTM4blffQXBM3H8xMj1uI7u6H-4Lxu7siT-w73ixUR9nAOaV9NX2V-dEvTgrG1CvkAeQqfwP9-1pV70SO4YVnG5u2SkVF9MhMOkuPx9IMP364ll1JKwwp4zMI2wPRVTc4EFYYZrx4tPxIIHMoVo8i5DJEfBCTWdkNfrZc3K2VFNjbJSfusGLoUdaCKNQRPqWRrhDgcv3ns0oLTsf7uotu4AFEUZW9IUbdpHEtCrfBp3HcmV3W64xapHRPjARS9LUY8oyW21za47eJPHhEgA1A_xSbEYJVuZlSh9qkUkpV_O098iMjTJui2_TqNP73ULM-vABvJVqNeqm62UbBnlmXfA-YE4iVikXtHUS8hUltFFERtIQFEGPvcoQanMp2Tmlens305395y6OkFkh_P7KvN1S479IJtHtyWBCjj2tuvmyRMkgdZ_41GNv75axp6Z5qfoB3wHYGJMwigAb2X_1EyGAvR_x5um6rKixEk0gxbfuJKxmb_M5F5QbV9mqIMCh28c1Li4MGrr5QNn2vkki0pz9lpgfstO_JMomyxNmpyCvyQiybGyL8jkah5Szoh506v03IOpIY0w4-gNwaI7jM8YjTzFzxDbOq7EHiIyf-FZhp8KObDeaFDQkHH01f3eScNaF6nwMCgxi-zGuc_m560Hd-KtibOr8b",null,1,null,[1,null,null,null,["asd",null,true]]]',
"bgRequest": '["identifier","<_jJqMn8CAAa4w6ckuMON8dS2w0UDZI70ACkAIwj8Rm9120_FMecmAHE2_001Jum-u__T3RiKDE3L2Pjm9w84SdDDH80AAACcnQAAACanAQdWBVmTK72KnxQhEoGc_N8OmhUFlhlVwQf4HFpkeSBYHkaiRODvtroOa2vZZfGGqLEQs4CYM54Fw3B1QLO-4Warabpq6THEf-9HEl2qFrUnSYa_nh9sgySEuMrTqtF16Ob5_aPoE-adHJUj-30S6h6Gh1Qpq3cIqqNbniegIw_m8W93sBMw2sp6ln2sOSilYjNGVZPaSMYaRMkGswZHCEEsaiu4ySp9J5dfuWILJoxo1qXTQNpxTZo0koU340HsbPFIS7p7A6sUrKBEBlNDeIEi-kLCpSd3uHIPdNaX_dgXkyUKErYHUBW3rbUUsXjQxfqjXN6Wabe22InUvTGM74mwRGS9wattdDKSKTBxwZxzJ9NwqQz4yCrXN_fZZoCuxy7EWOR425ZXWKqKUFDTkWf2WPbTcCrMBxc5lqXA1hTrJ8IRH3OY6t-dKR82V6XYkJqXqI7cUO8c1aOT9ZnbNnziQbFU_yUVQuORbWyB8B50usaETdjL0cSnTLrDS9hOHU63zKwv5gnefo9_06NiLMcsOKg_vDQeCAqaMFIZ8WlmHC5UdMAsoHoY2pN6ddvkWqnkiJEaAMZ_XPtdnt3zip0toIX9cXKEWK3Ul_U7nrL-Ajc-01aL-4LFjGMoVtRKFPnSMtAp0MC1MzuBjSkUYMhxVlIJCBguHjXRvQC0L3QVCL0a2mwOI-JxnXD9_uFFm0PhLfdIAFi5Qh7HHMF7DVmD_wnD9pqhbku5fHiBHEOgZ-qgaVnp68l4q4oRuD8qCcGyrRhmKNcA-X6pQ8vGr8U0spexUKaXE2oX1VYHN2HO7zSgK12zIuIOKqY8oB_HHm16U4fkP96eIiiJgo6eMTqOwKTwUaeLeJGtOtXzCTr6_gf1RYgcQJVfNrUsq9GDksf6BBNjax0W8e8m01GLIp5_JUAn2wJsOVrAv2xWwCf8QePFltNb8WTwUfyDevIYmvaNqLwE7pNme8YG8lR7VFMHMcZcMjodreOm0pmXRUFoqtd-AHBXDQKgCV4VTQh1JpaukWbiezJtKS-NpvdKt9kF5V1qpMkdPV7hXHrmeN7mqsGabKqmY46p3pm08iGyFLIgi5B7xKwXmf6-t12DAx2py307tuwWmuMj2LnQL6lwd-hRIE26LoGtVFdixrVUxDD0-b-8aoDH2-AnJnBSXEqIgZ_QtGMthv4R5njD2Pb0j3HqvGFTxvHUwkooOxF-_hurfE8MWN7g565ZzToAU-YWFU6XNoo6PBNqRdNQ8jQWmDtrnqjP2pQ2qQhxU4o46_cKCW4QxftrcTEFcqYtWpoMu7uoYZ_pF0c-WijiGIGp0dxHULc5LRPGVFg3tq2SuoWX-ZKJuntM2OYq2OehrxMSy8Jnbl8XnmHWjg3Gof0NmvyJzc5KH5pgTXfCeYVx9MHBfAmDt_vpqY3VUyFulwHylYScS1nyvkfdUA5MJjDdOovWqzXJszO1yCpj6zqBXMyQTGGjFYrXjivoXF4FXuGtdL392X5XUXQynTRW272EdYv_5hqQX0ZWP22SBfHvlsbtdNij9NW_PUjVpGjI4V_UZYHXtnvjRo2C5vyUH-cIZ1lSwyFTdYpm3hWAu6bkDQFdtystdd8e4Bv3U5iuRpBaisoCjg1zUhBs3by9G5guhxPhvMiDLceUOejLYqI-jbHdvYua9mjhbloppFYBIGLJSQzrCiQbxoUyOn7I7VT2g1TXtU9ocaQ2GIhlPnrgrJoNZCqTAFfYQ_bItFI48aNqP4TxZUZbdI2_nPPf-l8e2-psoLOcWSzVfaMx3m5YNR-g34wXHTMWMZvw4_fq4OmWcEwiMf-4pczD9WZR"]',
'bghash': "ROtW1CCVGOr0w7MvmUBsLpVxox5AtfSjmXP93SJ5VZ4",
"azt": "AFoagUVFIqGyE2IWUipeF8VEovA7Ief2qA:1640898496602",
"cookiesDisabled": "false",
"deviceinfo": '[null,null,null,[],null,"US",null,null,null,"GlifWebSignIn",null,[null,null,[],null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,[5,"77185425430.apps.googleusercontent.com",["https://www.google.com/accounts/OAuthLogin"],null,null,"625361be-f220-4aa2-9e73-423c4bffb681",null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,5,null,null,[],null,null,null,null,[]],null,null,null,null,null,null,[],null,null,null,null,[]],null,null,null,null,1,null,false,1,""]',
"gmscoreversion": "undefined",
"checkConnection": "youtube:189:0",
"checkedDomains": "youtube",
"pstMsg": '1'
}
response = requests.post(url, data=data)
print(response.text.encode())
and it should return something like this
password is incorrect
I and look at the "f.req" at the very end of that line. it says the password (I think) which is "asd" next to some nulls. The asd is the incorrect password. What im trying to do is test if that password is incorrect, and if it is, it will return like incorrect password, and if it is correct, it will return correct password. Can someone please help me because I dont know how to test if it is incorrect or correct.

DUO-LABS WebAuthn: Server validation of credential failed: registration failed. error: registration rejected. error: unable to verify origin

I tried implementing a fingerprint-based authentication using DUO-lab's Python's webauthn package. I however ran into this error:
server validation of credential failed: registration failed. error: registration rejected. error: unable to verify origin..
When I checked the package's source code, I noticed this error unable to verify origin.. was raised when maybe your authenticator wasn't properly configured.
Is there a way I can specifically state that I only need platform authenticators rather than roaming authenticators without thickering with the package's source code? If there is, kindly include a full working code for Flask(This is what I am using now after the error chased me out of Django). My current configurations are:
RP_ID = 'nacesdecide.herokuapp.com' #The app is currently hosted on heroku
RP_NAME = 'nacesdecides nacesdecide'
ORIGIN = 'https://nacesdecide.herokuapp.com/'
The application is currently on heroku and can be accessed live via naces register. I want the application to use platform authenticators alone.
Update:
Some part of the code, on the client side (drafted from duo-lab's python webauthn flask demon js, is:
/**
* REGISTRATION FUNCTIONS
*/
/**
* Callback after the registration form is submitted.
* #param {Event} e
*/
const didClickRegister = async (e) => {
e.preventDefault();
// gather the data in the form
const form = document.querySelector("#register-form");
const formData = new FormData(form);
// post the data to the server to generate the PublicKeyCredentialCreateOptions
let credentialCreateOptionsFromServer;
try {
credentialCreateOptionsFromServer = await getCredentialCreateOptionsFromServer(
formData
);
} catch (err) {
showErrorAlert(`Failed to generate credential request options: ${err}`);
return console.error("Failed to generate credential request options:", err);
}
// convert certain members of the PublicKeyCredentialCreateOptions into
// byte arrays as expected by the spec.
const publicKeyCredentialCreateOptions = transformCredentialCreateOptions(
credentialCreateOptionsFromServer
);
// request the authenticator(s) to create a new credential keypair.
let credential;
*try {
credential = await navigator.credentials.create({
publicKey: publicKeyCredentialCreateOptions,
});*
} catch (err) {
showErrorAlert(`Error creating credential: ${err}`);
return console.error("Error creating credential:", err);
}
// we now have a new credential! We now need to encode the byte arrays
// in the credential into strings, for posting to our server.
const newAssertionForServer = transformNewAssertionForServer(credential);
// post the transformed credential data to the server for validation
// and storing the public key
let assertionValidationResponse;
try {
assertionValidationResponse = await postNewAssertionToServer(
newAssertionForServer
);
} catch (err) {
showErrorAlert(`Server validation of credential failed: ${err}`);
return console.error("Server validation of credential failed:", err);
}
// reload the page after a successful result
setTimeout(function () {
window.location.href = Flask.url_for("accounts.login");
}, 1000);
// window.location.reload();
};
On the server side, we have:
def webauthn_begin_activate():
# MakeCredentialOptions
username = request.form.get('register_username')
display_name = request.form.get('register_display_name')
if not util.validate_username(username):
return make_response(jsonify({'fail': 'Invalid username.'}), 401)
if not util.validate_display_name(display_name):
return make_response(jsonify({'fail': 'Invalid display name.'}), 401)
if User.query.filter_by(username=username).first():
return make_response(jsonify({'fail': 'User already exists.'}), 401)
#clear session variables prior to starting a new registration
session.pop('register_ukey', None)
session.pop('register_username', None)
session.pop('register_display_name', None)
session.pop('challenge', None)
session['register_username'] = username
session['register_display_name'] = display_name
challenge = util.generate_challenge(32)
ukey = util.generate_ukey()
# We strip the saved challenge of padding, so that we can do a byte
# comparison on the URL-safe-without-padding challenge we get back
# from the browser.
# We will still pass the padded version down to the browser so that the JS
# can decode the challenge into binary without too much trouble.
session['challenge'] = challenge.rstrip('=')
session['register_ukey'] = ukey
*make_credential_options = webauthn.WebAuthnMakeCredentialOptions(
challenge, RP_NAME, RP_ID, ukey, username, display_name,
'https://example.com')*
return jsonify(make_credential_options.registration_dict)
This function might also be of interest:
def verify_credential_info():
challenge = session['challenge']
username = session['register_username']
display_name = session['register_display_name']
ukey = session['register_ukey']
registration_response = request.form
trust_anchor_dir = os.path.join(
os.path.dirname(os.path.abspath(__file__)), TRUST_ANCHOR_DIR)
trusted_attestation_cert_required = True
self_attestation_permitted = True
none_attestation_permitted = True
webauthn_registration_response = webauthn.WebAuthnRegistrationResponse(
RP_ID,
ORIGIN,
registration_response,
challenge,
trust_anchor_dir,
trusted_attestation_cert_required,
self_attestation_permitted,
none_attestation_permitted,
uv_required=False) # User Verification
try:
webauthn_credential = webauthn_registration_response.verify()
except Exception as e:
return jsonify({'fail': 'Registration failed. Error: {}'.format(e)})
# Step 17.
#
# Check that the credentialId is not yet registered to any other user.
# If registration is requested for a credential that is already registered
# to a different user, the Relying Party SHOULD fail this registration
# ceremony, or it MAY decide to accept the registration, e.g. while deleting
# the older registration.
credential_id_exists = User.query.filter_by(
credential_id=webauthn_credential.credential_id).first()
if credential_id_exists:
return make_response(
jsonify({
'fail': 'Credential ID already exists.'
}), 401)
existing_user = User.query.filter_by(username=username).first()
if not existing_user:
if sys.version_info >= (3, 0):
webauthn_credential.credential_id = str(
webauthn_credential.credential_id, "utf-8")
webauthn_credential.public_key = str(
webauthn_credential.public_key, "utf-8")
user = User(
ukey=ukey,
username=username,
display_name=display_name,
pub_key=webauthn_credential.public_key,
credential_id=webauthn_credential.credential_id,
sign_count=webauthn_credential.sign_count,
rp_id=RP_ID,
icon_url='https://example.com')
db.session.add(user)
db.session.commit()
else:
return make_response(jsonify({'fail': 'User already exists.'}), 401)
flash('Successfully registered as {}.'.format(username))
return jsonify({'success': 'User successfully registered.'})
Second update: The full log below is what I have got:
webauthn.js:101
{id: "ATdDPQneoYF3tA6HYW8_dr2eBDy53VNoEIHRWUDfnmT2URKIs0SQ_lQ7BujdmcfM9Hc2xNH8bvLf4k3lQJ-7RX4",
rawId: "ATdDPQneoYF3tA6HYW8_dr2eBDy53VNoEIHRWUDfnmT2URKIs0SQ_lQ7BujdmcfM9Hc2xNH8bvLf4k3lQJ-7RX4",
type: "public-key",
attObj: "o2NmbXRkbm9uZWdhdHRTdG10oGhhdXRoRGF0YVjFD32HDgTSvc6zIlggmLLxXTKQyiabSwuLWNiTpJ3WQfmMoC_qX_QTuWPWHo4",
clientData: "eyJ0eXBlIjoid2ViYXV0aG4uY3JlYXRlIiwiY2hhbGxlbmdlIj9pZFBhY2thZ2VOYW1lIjoiY29tLmFuZHJvaWQuY2hyb21lIn0", …}
attObj: "o2NmbXRkbm9uZWdhdHRTdG10oGhhdXRoRGF0YVjFD32HDgTSvcJxUiUIT6ViS4biCWKTR25PIW3beO9V5NdFAAAAALk_2WHy5kYvsSKCACJH3ngAQQE3Qz0J3qGBd7QOh2FvP3a9ngQ8ud1TaBCB0VlA355k9lESiLNEkP5UOwbo3ZnHzPR3NsTR_G7y3-JN5UCfu0V-pQECAyYgASFYID93HTRf5UtMsCsW9D5TyWQDSgMW2MDhiYWKnz3sq16zIlggmLLxXTKQyiabSwuLWNiTpJ3WQfmMoC_qX_QTuWPWHo4"
clientData: "eyJ0eXBlIjoid2ViYXV0aG4uY3JlYXRlIiwiY2hhbGxlbmdlIjoidFNOS3g5RnVyWFI4dlhVdVBkVms5azhDcEhlMWMydnlrbkdwYUhseXZKYyIsIm9yaWdpbiI6Imh0dHBzOlwvXC9uYWNlc2RlY2lkZS5oZXJva3VhcHAuY29tIiwiYW5kcm9pZFBhY2thZ2VOYW1lIjoiY29tLmFuZHJvaWQuY2hyb21lIn0"
id: "ATdDPQneoYF3tA6HYW8_dr2eBDy53VNoEIHRWUDfnmT2URKIs0SQ_lQ7BujdmcfM9Hc2xNH8bvLf4k3lQJ-7RX4"
rawId: "ATdDPQneoYF3tA6HYW8_dr2eBDy53VNoEIHRWUDfnmT2URKIs0SQ_lQ7BujdmcfM9Hc2xNH8bvLf4k3lQJ-7RX4"
registrationClientExtensions: "{}"
type: "public-key"__proto__: Object
webauthn.js:107 Server validation of credential failed: Registration failed. Error: Registration rejected. Error: Unable to verify origin..
didClickRegister # webauthn.js:107
async function (async)
didClickRegister # webauthn.js:68
I think the issue is that there's a trailing slash on your ORIGIN value.
Peering into the attestation response's cliendDataJSON, the origin is reported as "https://nacesdecide.herokuapp.com":
Looking at how the Duo WebAuthn library verifies this response, the basic origin comparison is failing because your ORIGIN of "https://nacesdecide.herokuapp.com/" is not equivalent to the response's origin:
Response: "https://nacesdecide.herokuapp.com"
ORIGIN: "https://nacesdecide.herokuapp.com/"
If you remove that trailing slash then I'll bet everything will verify as expected.
#IAmKale answer solved the initial problem. However, it is important to be aware that you might run into server error: unexpected token < in JSON at position 0. I haven't found a concrete solution to this but ensuring that distinct username is used for registration fixed it. Also, it seems distinct devices are required for multiple registrations — one device per registration.

MultiValueDictKeyError varies in localhost and Heroku host

I'm currently learning django and I've created a simple TODO project which has an otp authentication feature. While running the project in localserver otp was generated and stored in the model which is then matched by using if (t.otp == int(request.POST['otp'])): where t is a model object. This works perfectly fine. While I deployed the same in heroku server with DEBUG = True for testing purpose, it is throwing MultiValueDictKeyError in line if (t.otp == int(request.POST['otp'])):. Initially t.opt is set to the value generated and it is reinitialized to 0 once the user enters the correct OTP and registers. Kindly notice the comments in the code that explains the issue a bit more.
My views.py goes as (I've removed some elif part that are not required to reduce the number of lines),
def regsub(request):
if(request.method=="POST"):
uname = request.POST['username']
fname = request.POST['fname']
lname = request.POST['lname']
email = str(request.POST['email'])
pass1 = request.POST['pass1']
try: **#this tries to get the values pass1 and pass 2 whereas except gets the value otp**
if(request.POST['pass1']==request.POST['pass2']):
dictpass = {
'username':uname,
'fname':fname,
'lname':lname,
'email':email,
'password':pass1,
}
the_otp = r.randint(100000,999999)
try:
t=temp.objects.create(name=uname,otp=the_otp)
t.save()
except(IntegrityError):
return render(request,'register.html',{'flag':True,'msg':"Username already exits! Please try again."})
sub = "OTP for registration"
msg = "Some Message " + the_otp
from_email = settings.EMAIL_HOST_USER
to_email = [request.POST['email'],]
send_mail(sub,msg,from_email,to_email)
messages.info(request,"Password Verified! Please Enter the OTP sent to your email.")
return render(request,'register.html',dictpass)
except:
t = temp.objects.get(name=uname)
if (t.otp == int(request.POST['otp'])): **#the flow directly hits here after saving the otp in the model(send_mail part is not executed in try), also throws MultiValueDictKeyError**
user = User.objects.create_user(username=uname, first_name=fname, last_name=lname, email=email, password=pass1)
t.otp = 0
t.save()
user.save()
task.save()
sub = "Account creation successful"
msg = "Some Congrats message"
from_email = settings.EMAIL_HOST_USER
to_email = [request.POST['email'],]
send_mail(sub,msg,from_email,to_email)
messages.info(request,"Account has been created Successfully!")
return render(request,'login.html')
else:
return render(request,'register.html',{'flag':True})
The above code works good in localhost whereas fails in heroku. I have used heroku postgres in production.

Internal Server Error: when trying to use flask-mail

I am trying to send mail to the user through flask-mail. This code shown below works fine on the localhost. But when I deployed my flask app to AWS Elastic Beanstalk and use the send_reset_email function, it throws me Internal Server Error. Where should I change my code? Any help will be appreciated.
My config code:
application = Flask(__name__)
application.config['SECRET_KEY'] = '-------'
application.config["MONGO_URI"] = "mongodb+srv://------"
mongo = PyMongo(application)
db = mongo.db
bcrypt = Bcrypt(application)
application.config['MAIL_SERVER'] = 'smtp.googlemail.com'
application.config['MAIL_PORT'] = 587
application.config['MAIL_USE_TLS'] = True
application.config['MAIL_USERNAME'] = '----'
application.config['MAIL_PASSWORD'] = '----'
mail = Mail(application)
My function file:
def get_reset_token(username, expires_sec=1800):
s = Serializer(application.config['SECRET_KEY'], expires_sec)
return s.dumps({'user': username}).decode('utf-8')
def verify_reset_token(token):
s = Serializer(application.config['SECRET_KEY'])
try:
username = s.loads(token)['user']
except:
return None
user = db.user.find_one({ 'username' : username })
return user
def send_reset_email(user):
token = get_reset_token(username=user['username'])
msg = Message('Password Reset Request',sender='----',recipients=[user['email']])
msg.body = f'''To reset your password, visit the following link:
{url_for('reset_token', token=token, _external=True)}
If you did not make this request then simply ignore this email and no changes will be made.
'''
mail.send(msg)
You can use mail.send_message() that takes in arguments title, sender, recipients and body. Here is a similar code that i used to send email activation token:
code_act = "127.0.0.1:5000/confirm-mail/"+token
mail.send_message("Account activation Link", sender="bot", recipients=email.split(), body="The activation link is " + code_act)

Client.put and Client.get requests fail when using web.py

I am building a relatively simple site for images and am building a login and registration system.
import porc
MY_API_KEY = '<REDACTED>'
client = porc.Client(MY_API_KEY)
dbUsername = dbinfo['username']
username = u'test'
if dbUsername != username:
send = client.put('bstego', u'testy', {
"username": u'testy',
"email": u'testing#test.com',
"URL": 'test.test'
})
success = client.get('bstego', u'testy')
print "Received "+success["username"]
The above code works and delivers perfectly. However, in my implementation with web.py if I use almost the exact verbatim code, I get a NoneType.

Categories