Skip to content

Latest commit

 

History

History
144 lines (98 loc) · 18.2 KB

README.md

File metadata and controls

144 lines (98 loc) · 18.2 KB

AuthV1

(authV1)

Overview

Operations that allow you to generate a Hathora-signed JSON web token (JWT) for player authentication.

Available Operations

  • 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.

loginAnonymous

Returns a unique player token for an anonymous user.

Example Usage

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();

Parameters

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.

Response

Promise<components.PlayerTokenObject>

Errors

Error Object Status Code Content Type
errors.ApiError 404 application/json
errors.SDKError 4xx-5xx /

loginNickname

Returns a unique player token with a specified nickname for a user.

Example Usage

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();

Parameters

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.

Response

Promise<components.PlayerTokenObject>

Errors

Error Object Status Code Content Type
errors.ApiError 404 application/json
errors.SDKError 4xx-5xx /

loginGoogle

Returns a unique player token using a Google-signed OIDC idToken.

Example Usage

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();

Parameters

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.

Response

Promise<components.PlayerTokenObject>

Errors

Error Object Status Code Content Type
errors.ApiError 401,404 application/json
errors.SDKError 4xx-5xx /