6 Users
Max edited this page 2015-03-01 16:02:32 +03:00

General

Your games do not authenticate users by using their username and password combination. Instead, users are given a "token" which they enter in to your game to verify themselves.

Usernames only contain alphanumeric characters, hyphens and underscores.

Authentication

Authenticates the user's information. This should be done before you make any calls for the user, to make sure that the user's credentials (username/token) are valid.

local success = GJ.authUser(name, token)

You can also check if user is authenticated using GJ.isLoggedIn

local ready = GJ.isLoggedIn

Make sure you logged in successfully before you start playing with trophies, scores, etc.

You can also get user credentials from file that gamejolt.lua automatically creates if user's using Quick Play.

local success, username, token = GJ.getCredentials(directory)

When authentication is done, you can get username and token in any time using GJ.username and GJ.userToken, like this:

print("The username is " .. GJ.username .. " and token is " .. GJ.userToken)

Fetching user's info

There are two ways to fetch information about specific user.

By username:

local userInfo = GJ.fetchUserByName(name)

By user id:

local userInfo = GJ.fetchUserByID(id)

They're equivalent and return a table formatted like this:

  • id - The ID of the user.
  • type - Can be "User" or "Developer".
  • username - The user's username.
  • avatar_url - The URL of the user's avatar.
  • signed_up - How long ago the user signed up.
  • last_logged_in - How long ago the user was last logged in. Will be "Online Now" if the user is currently online.
  • status - "Active" if the user is still a member on the site. "Banned" if they've been banned.

The fields below are only returned if the user is a developer.

  • developer_name - The developer's name.
  • developer_website - The developer's website, if they put one in.
  • developer_description - The description that the developer put in for themselves. HTML tags and new lines have been removed.

Example:

local userInfo = GJ.fetchUserByName("CROS")
local status = userInfo.status