(authV1)
Operations that allow you to generate a Hathora-signed JSON web token (JWT) for player authentication.
- loginAnonymous - Returns a unique player token for an anonymous user.
- loginNickname - Returns a unique player token with a specified nickname for a user.
- loginGoogle - Returns a unique player token using a Google-signed OIDC
idToken
.
Returns a unique player token for an anonymous user.
import { HathoraCloud } from "@hathora/cloud-sdk-typescript";
const hathoraCloud = new HathoraCloud({
appId: "app-af469a92-5b45-4565-b3c4-b79878de67d2",
});
async function run() {
const result = await hathoraCloud.authV1.loginAnonymous("app-af469a92-5b45-4565-b3c4-b79878de67d2");
// Handle the result
console.log(result)
}
run();
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
appId |
string | ➖ | N/A | [object Object] |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. | |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
Promise<components.PlayerTokenObject>
Error Object | Status Code | Content Type |
---|---|---|
errors.ApiError | 404 | application/json |
errors.SDKError | 4xx-5xx | / |
Returns a unique player token with a specified nickname for a user.
import { HathoraCloud } from "@hathora/cloud-sdk-typescript";
const hathoraCloud = new HathoraCloud({
appId: "app-af469a92-5b45-4565-b3c4-b79878de67d2",
});
async function run() {
const result = await hathoraCloud.authV1.loginNickname({
nickname: "squiddytwoshoes",
}, "app-af469a92-5b45-4565-b3c4-b79878de67d2");
// Handle the result
console.log(result)
}
run();
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
nicknameObject |
components.NicknameObject | ✔️ | N/A | |
appId |
string | ➖ | N/A | [object Object] |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. | |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
Promise<components.PlayerTokenObject>
Error Object | Status Code | Content Type |
---|---|---|
errors.ApiError | 404 | application/json |
errors.SDKError | 4xx-5xx | / |
Returns a unique player token using a Google-signed OIDC idToken
.
import { HathoraCloud } from "@hathora/cloud-sdk-typescript";
const hathoraCloud = new HathoraCloud({
appId: "app-af469a92-5b45-4565-b3c4-b79878de67d2",
});
async function run() {
const result = await hathoraCloud.authV1.loginGoogle({
idToken: "eyJhbGciOiJSUzI1NiIsImtpZCI6ImZkNDhhNzUxMzhkOWQ0OGYwYWE2MzVlZjU2OWM0ZTE5NmY3YWU4ZDYiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJhY2NvdW50cy5nb29nbGUuY29tIiwiYXpwIjoiODQ4NDEyODI2Nzg4LW00bXNyYjZxNDRkbTJ1ZTNrZ3Z1aTBmcTdrZGE1NWxzLmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwiYXVkIjoiODQ4NDEyODI2Nzg4LW00bXNyYjZxNDRkbTJ1ZTNrZ3Z1aTBmcTdrZGE1NWxzLmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwic3ViIjoiMTE0NTQyMzMwNzI3MTU2MTMzNzc2IiwiZW1haWwiOiJocGFdkeivmeuzQGdtYWlsLmNvbSIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJhdF9oYXNoIjoidno1NGhhdTNxbnVR",
}, "app-af469a92-5b45-4565-b3c4-b79878de67d2");
// Handle the result
console.log(result)
}
run();
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
googleIdTokenObject |
components.GoogleIdTokenObject | ✔️ | N/A | |
appId |
string | ➖ | N/A | [object Object] |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. | |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
Promise<components.PlayerTokenObject>
Error Object | Status Code | Content Type |
---|---|---|
errors.ApiError | 401,404 | application/json |
errors.SDKError | 4xx-5xx | / |