Skip to main content
Version: 2.x

UOdinTokenGenerator

A struct for generating ODIN tokens, employed for generating signed room tokens predicated on an access key. Be aware that access keys serve as your unique authentication keys, requisite for generating room tokens to access the ODIN server network. To ensure your security, it's strongly recommended that you NEVER embed an access key within your client code, and instead generate room tokens on a server.

Declaration
UCLASS(ClassGroup = Utility, BlueprintType, Blueprintable)
class ODIN_API UOdinTokenGenerator : public UObject
  • Header: #include "OdinTokenGenerator.h"
  • Module: Odin
  • Inherits from: UObject
  • Blueprint: Blueprint type, Blueprintable · Blueprint reference

Overview​

Functions​

NameDescription
ReleaseHandleFrees the native token generator (if any) and invalidates the handle wrapper in place.
ConstructTokenGeneratorConstructs a new instance of the UOdinTokenGenerator class.
SetAccessKey
GenerateRoomTokenGenerates a signed room token for authenticating access to a specific room within the ODIN server network.
GenerateRoomTokenExGenerates a signed room token with detailed customization options for connecting to the ODIN server network.
GetHandle
SetHandle

Functions​

ReleaseHandle​

Frees the native token generator (if any) and invalidates the handle wrapper in place. Safe to call during destruction; every path that frees the native handle must go through this, so the handle cannot be freed twice.

void ReleaseHandle();

ConstructTokenGenerator​

Static · Blueprint: Construct Token Generator

Constructs a new instance of the UOdinTokenGenerator class. This method is used to initialize a token generator object with a specified access key for generating authentication tokens.

UFUNCTION(BlueprintCallable, Category = "Odin|Authentication")
static UOdinTokenGenerator* ConstructTokenGenerator(UObject* WorldContextObject, const FString& AccessKey);
ParameterTypeDescription
WorldContextObjectUObject*A reference to the current world context.
AccessKeyconst FString&A string containing the unique access key required to generate authentication tokens. To maintain security, avoid embedding the access key in client code.

Returns UOdinTokenGenerator* – A pointer to the newly constructed UOdinTokenGenerator instance.

SetAccessKey​

void SetAccessKey(const FString& AccesssKey);
ParameterTypeDescription
AccesssKeyconst FString&

GenerateRoomToken​

Blueprint: Generate Room Token

Generates a signed room token for authenticating access to a specific room within the ODIN server network. This method also creates a JSON object containing the generated token and associated room ID, which can be used for further integration or debugging purposes.

UFUNCTION(BlueprintCallable, Category = "Odin|Authentication")
void GenerateRoomToken(
const FString& RoomId,
const FString& UserId,
UOdinJsonObject*& JsonAuth,
FString& Token);
ParameterTypeDescription
RoomIdconst FString&The identifier of the room for which the token is being generated. This is typically a unique string representing the specific room within the service.
UserIdconst FString&The identifier of the user requesting the token. This is a unique value representing the user within the context of the application.
JsonAuthUOdinJsonObject*&A reference to a UOdinJsonObject pointer that will be populated with a JSON structure containing details about the generated token and its associated room ID.
TokenFString&A reference to a string that will hold the generated authentication token if successful.

GenerateRoomTokenEx​

Const

Generates a signed room token with detailed customization options for connecting to the ODIN server network. The method signs a JSON body with user, room, and additional metadata to construct the token.

FString GenerateRoomTokenEx(
const FString& RoomId,
const FString& UserId,
const FString& CustomerId = "",
const FString& Audience = "",
const FString& Subject = "",
const FString& Address = "",
const FString& Upstream = "",
const int32 Leeway = 300) const;
ParameterTypeDescription
RoomIdconst FString&The identifier of the room for which the token is being generated.
UserIdconst FString&A unique identifier of the user for whom the token is being created.
CustomerIdconst FString&An optional identifier for the customer creating the token. Default: "".
Audienceconst FString&An optional audience field. Default: "".
Subjectconst FString&An optional subject field. Default: "".
Addressconst FString&An optional address field. Default: "".
Upstreamconst FString&An optional upstream field. Default: "".
Leewayconst int32An integer representing the lifetime duration in seconds for the token after its creation. Default: 300.

Returns FString – A signed token string that grants access to the specified room with the provided configuration. Returns an empty string if token generation fails.

GetHandle​

Const · Inline

OdinTokenGenerator* GetHandle() const;

Returns OdinTokenGenerator*

SetHandle​

Inline

void SetHandle(OdinTokenGenerator* handle);
ParameterTypeDescription
handleOdinTokenGenerator*