Skip to main content

OAuth

The LITauth OAuth implementation is very similar to Discord's.

LITauth follows the OAuth 2.0 protocol, im not gonna write docs that are any better so just look at Discord's ones.

OAuth URLs

URLMethodContent TypeParametersDescription
/api/oauth2/tokenPOSTapplication/x-www-form-urlencodedgrant_type, code and redirect_uri.
client_id and client_secret should be passed in as HTTP Basic authentication, however also supported in the request body
Provides an accessToken and refreshToken for a valid authentication code (obtained via /oauth/authorize)
Tokens expire in 7 days, after which you must reauthorize or refresh token
/api/oauth2/tokenPOSTapplication/x-www-form-urlencodedgrant_type and refresh_token.
client_id and client_secret should be passed in as HTTP Basic authentication, however also supported in the request body
Provides a refreshed accessToken for a valid refresh token
Tokens expire in 7 days, after which you must reauthorize or refresh token
/oauth/authorizeGETurl query you knowclient_id, redirect_uri, scope (space seperated) and optionally, stateRedirect your user here to authorize your application

API URLs

All endpoints marked authorized require Bearer token in Authorization header.

URLMethodAuthorizedParametersScopesDescription
/api/userGETyesnoneidentifyReturns user information, without email
/api/user/emailGETyesnoneidentify, emailReturns user information with email
/api/avatarPOSTyescolor and background hex codesavatarChanges the user avatar, returns 200 OK if successful
/api/avatar/:userIdGETno:userId should be the id of the usernoneReturns the user avatar as SVG
/api/avatar/bg/:userIdGETno:userId should be the id of the usernoneReturns the user avatar as SVG with the background