alekfart/rbx_oauth

Roblox OAuth library

Roblox OAuth for Luau

strictly typed | OOP based design | smart HTTP client | explicit error handling

Danger

If you plan to use a confidential client, you SHOULD use a cryptographically secure 43-128 bit code verifier.

Api coverage

Unless a legacy endpoint is necessary, it will not be supported.

FeatureCoverage
Assets~ localization tables
Data and memory storesX
Groups~ shout, join requests, and membership filtering not supported
Luau executionX
MessagingX
MonetizationX
Universes and placesX
Users~ notifications not supported

Examples

Basic exponential retry

Tip

Whatever you return from the retry will be passed into the next call's parameters.

local task = require("@lune/task")

local retry = function(tries: number?): (boolean, number?)
 tries = if tries then tries + 1 else 1
 if tries > 3 then return false, nil end

 task.wait(1.5 ^ tries)
 return true, tries
end

Primitive limiter

Warning

This may cause large wait times. It is purely an example.

local OAuth = require("path/to/OAuth")
local task = require("@lune/task")

local limiter: OAuth.Limiter = function(method, url)
 return function(limit, remaining, reset)
  if remaining <= 0 then task.wait(reset) end
  return true
 end
end

Getting a User Thumbnail

Tip

Most methods will return the following pattern: (result, error, response).

local OAuth = require("path/to/OAuth")

local client = OAuth.clients.apiKey.new("ApiKey")

local user, clientErr = client.users:Get("987654321")
if not user then error(clientErr) end

local thumbnailLocation, thumbnailErr = user:GenerateThumbnail()
if not thumbnailLocation then error(thumbnailErr) end

local result, operationErr = thumbnailLocation:Wait()
if not result then error(operationErr) end

local fetchResponse = client:Get(result.imageUri)

Contributing

To request features or endpoints just make an issue, I will get to it as soon as I find time. (better yet, just make a pull)

Roadmap

  1. Finishing up currently supported features
  2. Support for Lute
  3. Tests (Making tests is just doubting your code and intelligence)
  4. Universe & Place Apis