authtoken - session login

its like schizod2k says, we expected it to return some kind of info or a confirmation that you had been logged in with the authtoken as described in the guide. You should remove this so others dont get confused by this as well.

so instead of using cloud.isLoggedIn I now have to figure out a different way to at least check for online connection before logging in and notifying the user that he needs to check his device connection if its off. Just logging in and assuming everything is fine like with authtoken is not an option. There are devices out there that isnt always online and the user must be notified else they just get mad and shout broken app and give you one star ratings :slight_smile:

@schizoid2k, that’s probably my fault, when I wrote the guide.  I missed it.  I’ll see if we can get that revised.

@borgb, there are plenty of ways of checking for a network connection without depending on the cloud’s login.  But if you think you’re logged in, you could hit one of the API’s like getting the users profile and see if that returns and error or not.

Thanks Rob… Your last comment also gives me an idea as well… We can check for connectivity by calling a cloud function to see if there is an error. That’s a workable solution for me.

I am using the code from aukStudios here to check for internet connection:

http://forums.coronalabs.com/topic/33356-check-for-internet-connection/?hl=%2Bdevice+%2Bconnection#entry172766

works like a charm :slight_smile:

Now onto tackling the matchmaking part of corona cloud :slight_smile:

Hi,

The process is that you login with username/password to retrieve the auth_token.

At this point you don’t need to login again, you just need to pass the auth_token when you are making calls.

Thanks

-Mohamed

so you dont use the authtoken to log in? but the manage cloud users guide say that is one of the ways of logging in? Its not that its a problem, using email and password instead works fine. Just want to have it clear :slight_smile: Thanks!

Yes, I wondered that myself.

I was not sure I am making everything right so I didn’t post, but I can confirm the session login does not work.

It would be the preferred way for most users I guess, they would not be happy if they know you are storing their password somewhere on the phone.

Not sure I understood you correctly, but you don’t actually need or should store the user’s username and password.

All you need to store is that auth_token, which as I mentioned you can pass it with the calls so the data is associated with that user.

Hope that makes sense.

Can you let me know what you mean by the session login does not work?

Thanks

-Mohamed

When the user quits the game and returns later, I have a button “Last user” which should login the last player automatically (so he must not enter the email/password every time, as we have for the simulator - boring).

For this scenario I thought I will use this :

<docs>

Session Login

Once a user is registered and logged in, you can save the authToken
and, in future sessions of the app, log the user in using the token.
Alternatively, you can store the user’s email and password and use them
to log in the user as shown under Email/Password Login above.

local loginParams = {}

loginParams.type = “session”
loginParams.authToken = currentAuthToken

cloud.login( loginParams )

If the login is successful, the authListener() function will be called with an event type of “sessionLoggedIn”.

</docs>

So in the docs you suggest we can store the emaail/password and then use it for later login, what I did because the session login does not work (if I call the above code no event is triggered).

Hope this clarifies what we mean.

yeah, what ubj3d says. I also have a function that logs in the previous user so they dont have to do the login/password every session. But that dosent work with the authtoken session login as described. so now I have to store e-mail/password until I can get authtoken to work.

I’ll discuss with the team and get clarification on this.

In the mean time, I can assure you that you don’t need to store the username and password, all you need is the authToken.

In other words, you don’t need to pass the username/pw again get the authToken, you can continue using the one you received on first log in.

Sorry about the confusion.

Thanks

-Mohamed

I just got this working recently, and this is what I noticed. Maybe this will help. 1. Are you still calling cloud.init? I don’t see it in the little sample of code above, so just making sure. 2. For authToken, are you checking for event.type “sessionLoggedIn”? 3. If you are using storyboard, your require variable has to be the same name. I had cloud = require “cloud” in one scene and coronaCloud = require “cloud” in another scene. The authToken was not available in my scene with coronaCloud defined since I called the init with cloud. Hope this helps. If not, post your listener.

Wow.

As strange as this is… logging in via authToken is no longer working for me.  :frowning:

I had no problem for several days, and now I have the exact same problem.  My auth listener is never called when trying to log in via authToken.  Loggin in via email/password does work as expected.

Any update on this topic?

The same problem here, token login never work.

Hi guys,

I have asked the team to looking why this is happening, I will keep you posted.

Thanks

-Mohamed

What messages are you getting in your console log? Do you have debugging on for the cloud to get more messages on what’s going on?

as stated above by me and others, nothing is happening. no error, no output, nothing. and I have tried it with cloud.debugEnabled = true

if this should work and others are getting this to work then it would be great to se some code of this.  Currently I am saving email and password for login.

Hi,

While Rob is looking into this, may I suggest that instead of saving the email and password, save the auth_token only.

Then you don’t have to login, just load the auth_token and pass it with your calls.

-Mohamed

Can you post your code please?

Here is what I have… somewhat cleaned up.  Maybe others in this thread can post some code as well.

[lua]

cloud = require “cloud”

function ccLoginListener(event)

    if event.type == “sessionLoggedIn” or event.type == “loggedIn” then

        if not event.error then

              – do stuff like get achievements

              print “No errors”

        else

            alert = native.showAlert(“Error”, event.error, {“OK”})

        end

    end

end

cloud.init(ACCESSKEY, SECRETKEY, ccLoginListener)

cloud.login({type = “session”, authToken = PREV_SAVED_TOKEN})

[/lua]

Now, if I replace the cloud login command with this…

[lua]

cloud.login({type = “user”, email = MY_EMAIL_ADDR, password = MY_PASSWORD})

[/lua]

… then the event listener is called.  Using the session login, the listener is never called.

I have Lua Glider, and placed a breakpoint inside ccLoginListener, and it is never trapped when using session login.  I just tried it with build 2013.1095, and previously with 2013.1080

–john