Closed
Description
Issue Description
I Have the following cloud code which I am trying to execute without session token on android i am getting unauthorized even after setting useMasterKey as mentioned in docs. Am i missing something?
Parse.Cloud.define("sendotp", function (request, response) {
var mobile_no = request.params.mobile_no;
var Usr = new Parse.Query(Parse.User)
Usr.equalTo("phone", mobile_no);
Usr.first({ useMasterKey: true,
success: function (usr) {
// The object was retrieved successfully.
if (usr.id != null) {
Parse.Cloud.httpRequest({
method: 'POST',
headers: {
'Content-Type': 'application/json;charset=utf-8',
'application-Key': 'KEYREMOVED'
},
url: 'https://sendotp.msg91.com/api/generateOTP',
body: {
countryCode: "91",
mobileNumber: mobile_no,
getGeneratedOTP: true
},
sucess: function (httpResponse) {
// success
var otpres = JSON.parse(httpResponse.text);
usr.set("newOTP", otpres.response.oneTimePassword);
usr.save(null, { useMasterKey: true,
success: function (user) {
response.success('OTP Sent Successfully!')
},
error: function () {
response.error('Sending OTP Failed! Please try again!');
}
});
},
error: function (httpResponse) {
// error
response.error('Sending OTP Failed! Please try again!');
}
});
}
},
error: function (error) {
response.error("No such user is found, kindly check your mobile no!");
}
});
});
Expected Results
{
"message": "OTP Sent Successfully!"
}
Actual Outcome
{
"code": 141,
"error": "unauthorized"
}
Environment Setup
-
Server
- parse-server version : 2.3.6
- parse node module version: 1.9.2
- Operating System: Linux on Heroku
- Hardware: Heroku
- Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): Heroku
-
Database
- Hosted on: mLab
Logs/Trace
Heroku Logs
2017-03-11T21:38:30.762860+00:00 heroku[router]: at=info method=POST path="/api/functions/sendotp" host=******.herokuapp.com request_id=a22f5699-093f-4b15-a5fe-b121e0cf2ebe fwd="54.196.45.207" dyno=web.1 connect=0ms service=3ms status=403 bytes=466 protocol=https
2017-03-11T21:38:30.725571+00:00 app[web.1]: warn: Making outgoing webhook request without webhookKey being set!
2017-03-11T21:38:30.764286+00:00 app[web.1]: error: Failed running cloud function sendotp for user undefined with:
2017-03-11T21:38:30.764290+00:00 app[web.1]: Input: {"mobile_no":"9908640059"}
2017-03-11T21:38:30.764292+00:00 app[web.1]: Error: {"code":141,"message":"unauthorized"} functionName=sendotp, code=141, message=unauthorized, mobile_no=9908640059, user=undefined
2017-03-11T21:38:30.765000+00:00 app[web.1]: error: Error generating response. ParseError { code: 141, message: 'unauthorized' } code=141, message=unauthorized
2017-03-11T21:38:30.765999+00:00 app[web.1]: error: unauthorized code=141, message=unauthorized
Metadata
Metadata
Assignees
Labels
No labels