create user profile not working on corona?

0 votes

Hello

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
thanks
asked Jul 4, 2014 in Discuss & suggest API by safvantai123 (24 points)

1 Answer

+1 vote
 
Best answer

Hi,

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.

Thanks.

 

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:
App42Log:setDebug(true)
Thanks.
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")
 end
 
end

function profileCallBack:onException(object)
 
  print(object:getAppErrorCode())
  print(object:getMessage())
 
end

function getUserCallBack:onSuccess(object)
      --for adding gender on profile
      local profileObj = object:getProfile()
    profileObj:setFirstName(profileObj:getFirstName());
    profileObj:setLastName(profileObj:getLastName());
    profileObj:setMobile(profileObj:getMobile());
    profileObj:setCountry(profileObj:getCountry());
    profileObj:setState(profileObj:getState());
    profileObj:setCity(profileObj:getCity());
    if gender == "Male" then
           profileObj:setSex(UserGender.MALE)
    elseif gender == "Female" then
          profileObj:setSex(UserGender.FEMALE)
    end
    App42Log:setDebug(true)
   -- print("username "..object:getUserName())
    userService:createOrUpdateProfile(object,profileCallBack)
end

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


function userResponseCallBack:onSuccess(object)
  userSessionId = object:getSessionId()
  if userSessionId ~=nil then
        App42API:setLoggedInUser(object:getUserName())
     userName = object:getUserName()
     print(object:getUserName())
     userService:getUser(App42API:getLoggedInUser(),getUserCallBack)
  end
  
 
end

function userResponseCallBack:onException(object)
  print(object:getAppErrorCode())
  
end



function main()

    userService:createUser("dice1","dice@1","dice1@gmail.com",userResponseCallBack)
end

main()


Thanks
Have you created the ACL app from AppHQ Management Console ?
Hi,
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:
http://api.shephertz.com/tutorial/Securing-Your-App/?index=security-acl
Let me know if it helps.

Thanks.
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 support@shephertz.com
...