Skip to main content
You can access auth methods via client.auth. When you call login() or refreshToken(), the module stores the accessToken and uses it for subsequent authenticated requests such as me() or updateProfile().

signUp

Create a new user account.
Example

login

Authenticate an existing user. The returned accessToken is stored internally.
Returns AuthResponse
Example

refreshToken

Rotate the current access token.
  • Browser: Call without arguments. It will automatically use the refreshToken stored in your HTTP-only cookies.
  • Mobile/Node: Pass the refreshToken string manually.

me

Fetch the profile of the currently authenticated user.

updateProfile

Update the authenticated user’s profile fields.
Example

changePassword

Change the authenticated user’s password.

Social auth

urBackend supports OAuth via GitHub and Google.

socialStart

You receive a URL to initiate the OAuth flow. Redirect your user’s browser to this URL.

socialExchange

Exchange the rtCode received at your callback URL for a refresh token.
Example

Account verification

Use these methods to handle email OTP flows.

publicProfile

Fetch a public-safe profile for any user by their username. This does not return sensitive fields like email or provider IDs.

logout

Call this to revoke your current session on the server and clear the local token.

Manual token management

If you need to manage tokens manually (for example, after social auth), you can use these helper methods:
  • getToken(): Returns the current in-memory access token.
  • setToken(token): Manually set the access token for the client.