Forum Multiplayer using auth field with connect()

Discussion and help relating to the PlayerIO Multiplayer API.

using auth field with connect()

Postby FlashHero » May 9th, 2010, 10:17 am

I'm trying to implement the secure login method using the auth field of PlayerIO.Connect. I followed the C# example and generated a hash based on a shared key and userid + ':' + unixtime. But somehow the server keeps returning a 'invalid/malformed' auth error.

I checked to see if the hash function was working properly, and it generated the exact same values from the C# example when I used the timestamp/key/userid presented there.

Is there something I'm missing here?
FlashHero
 
Posts: 5
Joined: May 9th, 2010, 9:57 am

Re: using auth field with connect()

Postby FlashHero » May 10th, 2010, 9:07 am

A new day brings the solution :). I figured out what I was missing.

I passed the generated hash to PlayerIO.Connect, but on a hunch I tried passing [unixtime + ':' + hash] and that did the trick! You might want to update the documentation concerning the auth field a little, perhaps.

For anyone interested, this is what needs to be passed to the auth field:

time = unixtime (number of seconds since 1-1-1970
user = the username to be authenticated
hash = SHA-1 HMAC hash of [time + ':' + user] using the secret key you entered in the admin panel

auth = time + ':' + hash

Then pass auth and user to the PlayerIO.Connect function.
FlashHero
 
Posts: 5
Joined: May 9th, 2010, 9:57 am

Re: using auth field with connect()

Postby Oliver » May 10th, 2010, 9:39 am

Which programming language are you using serverside to generate the auth ?

Would you mind sharing the code snippet, so we can put it up for others also?

- Oliver
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am


Return to Multiplayer