create user profile not working on corona?

0 votes


I am storing my player information on app42 cloudin corona sdk. I written my code in April 2014 and its working. Now i m using same code then it saying..

Exception 1401

Message UnAuthorized Access

Please check your credentials.
what was the problem i dont know.
please help me
asked Jul 4, 2014 in Discuss & suggest API by safvantai123 (24 points)

1 Answer

+1 vote
Best answer


Thanks for writing to us.

There are mainly 2 reasons of UnAuthorized Access (1401) Exception

-          Either your API Key & Secret Key is not correct

-          Or the device time is not correct on which app is running.

Could you please make sure that API Key and Secret Key are correct and also the time of the device is correct on which App is running.

Let me know if it helps.



answered Jul 4, 2014 by hs00105 (517 points)
selected Jul 7, 2014 by safvantai123
Thanks for your quick reply.
I checked my API key and Secret Key and that is correct.
and i am running on my mac pc simulator and date is also correct.
when i am registering user it will create user data but when i update profile it shows Exception.
Can you just print the logs while you are making the connection with App42 Server for profile update.
Put the below line when you are calling the update profile function:
I already print the logs and it saying

Exception 1401
Message UnAuthorized Access
Please check your credentials.
and i already have account registered on that credential why it showing this error.
Can you share the respective file that would be helpful to us for resolving your question?
Hi i am sharing this file please check it where i am putting wrong code.
local userName
local gender = "Male"
local App42Log = require("App42-Lua-API.App42Log")
local App42API = require("App42-Lua-API.App42API")
local User  = require("App42-Lua-API.User")
local Util = require("App42-Lua-API.Util")
local JSON = require("App42-Lua-API.JSON")
local profileCallBack = {}
local getUserCallBack ={}
local userResponseCallBack = {}
local userService = App42API:buildUserService()

function profileCallBack:onSuccess(object)
  if object:getUserName() ~= nil then
    print("callback gender "..object:getProfile():getSex())
   print("success register")

function profileCallBack:onException(object)

function getUserCallBack:onSuccess(object)
      --for adding gender on profile
      local profileObj = object:getProfile()
    if gender == "Male" then
    elseif gender == "Female" then
   -- print("username "..object:getUserName())

function getUserCallBack:onException(exception)
  App42Log.debug("Exception message is : "..exception:getMessage())

function userResponseCallBack:onSuccess(object)
  userSessionId = object:getSessionId()
  if userSessionId ~=nil then
     userName = object:getUserName()

function userResponseCallBack:onException(object)

function main()



Have you created the ACL app from AppHQ Management Console ?
Please pass the session id of the user in Service instance while making an API Call to make your data more secure. // Service instance is like you are making a request of userService then call the function userService:setSessionId("SessionId of User")
same for the other services as well.

For more details, kindly click on the below link which will explain that how you can secure your data:
Let me know if it helps.

Its working thank you so much....:)
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on