Learn how to integrate Argus Auth into your World Engine game client for seamless user authentication and identity management
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.
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
Copy
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
What's in the AuthUser object?
The AuthUser object contains user information from Argus Auth:
Copy
interface AuthUser { id: string name: string email: string // Additional user properties may be available}
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
Copy
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.