1.0.19 • Published 5 months ago

roblox-provider v1.0.19

Weekly downloads
-
License
ISC
Repository
-
Last release
5 months ago

Roblox Provider

A Roblox OpenCloud/OAuth2 Provider For NextAuth.


install:

npm i roblox-provider

example usage:

import { RobloxProvider, RobloxProviderCallbacks_Jwt } from "roblox-provider"

export const authOptions = {
  providers: [
    RobloxProvider({
      clientId: process.env.ROBLOX_ID,
      clientSecret: process.env.ROBLOX_SECRET,
      redirectUri: process.env.ROBLOX_REDIRECT,
      scopes: ["openid", "profile"],
      include: ["name", "displayName", "avatar"]
    })
  ],

  callbacks: RobloxProviderCallbacks_Jwt
}

(You can replace RobloxProviderCallbacks_Jwt with RobloxProviderCallbacks_Database if you are using database based sessions)


Roblox Provider Settings

clientId: string - Your roblox oauth2 client id.

clientSecret: string - Your roblox oauth2 client secret.

scopes: array - The permissions that your oauth2 app needs.

include: array - The data that will be saved to a session. Defaults to ["name", "displayName", "avatar"]. Valid values are name, displayName, avatar, description, created and hasVerifiedBadge. (the users RobloxID is always included so theres no need to define it here).

redirectUri: string - The url to redirect to.

checks: array - The security checks to perform during OAuth. defaults to ['pkce', 'state']. It is not advised to change this setting unless you know what you are doing.


If you want to add more callbacks as well you can do the following:

export const authOptions = {
  ...

  callbacks: {
    ...RobloxProviderCallbacks_Jwt,

    // example of another callback
    async redirect() {
      return 
    },
  },

  ...
}

If you want to add more functionality to the callbacks used by roblox-provider then you can do the following

import { RobloxProvider, RobloxProviderJwtCallback, RobloxProviderSessionCallback } from "roblox-provider"

export const authOptions = {
  ...

  callbacks: {
    async jwt({ token, user }) {
      token = await RobloxProviderJwtCallback(token, user)

      // add your code here

      return token
    },
  
    async session({ session, token }) {
      session = await RobloxProviderSessionCallback(session, token)

      // add your code here

      return session
    }
  },

  ...
}
1.0.19

5 months ago

1.0.18

5 months ago

1.0.17

5 months ago

1.0.16

8 months ago

1.0.9

11 months ago

1.0.8

11 months ago

1.0.11

11 months ago

1.0.10

11 months ago

1.0.15

9 months ago

1.0.14

9 months ago

1.0.13

9 months ago

1.0.12

11 months ago

1.0.7

12 months ago

1.0.6

12 months ago

1.0.5

12 months ago

1.0.4

12 months ago

1.0.3

12 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago