Nuxt plugin that facilitates BYU authentication features
npm install @byu-oit/nuxt-byu-auth:warning: Requires Nuxt version >= 2.13 :warning:
Install with yarn:
``shell script`
yarn add @byu-oit/nuxt-byu-auth
Install with npm:
`shell script`
npm install @byu-oit/nuxt-byu-auth
nuxt.config.js
`js`
module.exports = {
modules: [
'@nuxt/axios',
'@byu-oit/nuxt-alerts',
'@byu-oit/nuxt-byu-auth',
],
}
Using Plugin Options
TODO: commit this change
`js`
module.exports = {
modules: [
// ... other modules
['@byu-oit/nuxt-byu-auth', {
pluginOptions: {
'implicit-grant': { // configuration for the 'implicit-grant' plugin
usePkce: true, // use PKCE instead of the implicit grant flow
},
}
}]
],
}
Add the types to your "types" array in tsconfig.json after the @nuxt/types (Nuxt 2.12.0+)
tsconfig.json
`json`
{
"compilerOptions": {
"types": [
"@nuxt/types",
"@nuxtjs/axios",
"@byu-oit/nuxt-alerts",
"@byu-oit/nuxt-sis-context",
"@byu-oit/nuxt-byu-auth"
]
}
}
> Why?
>
> Because of the way nuxt works the $axios property on the context has to be merged into the nuxt Context interface via declaration merging. Adding @byu-oit/nuxt-byu-auth to your types will import the types from the package and make typescript aware of the additions to the Context interface.
Set the implicit auth environment variable in the nuxt.config file:`js``
{
publicRuntimeConfig: {
oauthCallbackUrl: process.env.OAUTH_CALLBACK_URL,
oauthClientId: process.env.OAUTH_CLIENT_ID,
baseUrl: process.env.OAUTH_BASE_URL, // defaults to https://api.byu.edu
autoRefreshOnTimeout: process.env.AUTO_REFRESH_ON_TIMEOUT // optional
}
}