1.0.19 • Published 2 years ago

roblox-provider v1.0.19

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years 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

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago