Skip to main content
This guide will walk you through integrating Argus Auth into your World Engine game client. Argus Auth provides secure, seamless authentication that works perfectly with multiplayer games.
We use the term Argus Auth and Argus ID interchangeably.

Prerequisites

Before you begin, make sure you have completed the Quickstart guide.

Sign in with Argus ID

Checking authentication state

Use world.auth.getUser() to get the current user. If this is your first time using Argus Auth, this will return null. You’d normally do this in the main menu of your game.
Main Menu
import { world } from './sdk'

export function mainMenu() {
  const user = world.auth.getUser()
  console.log(user)
}
The getUser() method returns either:
  • An AuthUser object if the user is authenticated
  • null if no user is currently signed in
The AuthUser object contains user information from Argus Auth:
interface AuthUser {
  id: string
  name: string
  email: string
  // Additional user properties may be available
}

Signing in

The following example shows how to sign in if no user is found. This is a simple example, on your game you might want to show a button to sign in.
Main Menu
import { world } from './sdk'

export async function mainMenu() {
  let user = world.auth.getUser()

  // Perform sign in if no user is found
  if (!user) {
    const { data, error } = await world.auth.signInWithArgusID()

    if (error) {
      console.error(error)
    } else {
      user = data
    }
  }

  // If there's still no user at this point, something went wrong
  if (!user) {
    alert('Failed to sign in, please try again')
  }
}
The signInWithArgusID() method automatically handles the auth flow, including opening the authentication popup and managing token. The token is stored in the browser’s local storage, therefore is persistent across reloads.

Handling User Logout

Use the logout() method to sign out the current user:
Logout
import { world } from './sdk'

export function handleLogout() {
  world.auth.logout()
  console.log('User has been logged out')
}

Next Steps

Now that you have authentication set up, you’re ready to learn about another World Engine concept: Subscribe Events.
I