I am following the Auth0 quick start with Vue
MainLayout.vue
I have a login button <div><button @click="login">Log in</button></div>
for this component
<script>
import { defineComponent, ref } from 'vue'
import EssentialLink from 'components/EssentialLink.vue'
export default defineComponent({
name: 'MainLayout',
components: {
EssentialLink
},
methods: {
login () {
this.$auth0.loginWithRedirect();
}
},
setup () {
const leftDrawerOpen = ref(false)
return {
essentialLinks: linksList,
leftDrawerOpen,
toggleLeftDrawer () {
leftDrawerOpen.value = !leftDrawerOpen.value
}
}
}
})
</script>
src/boot/auth0.js
I tried to register the plugin to my quasar bootfile (equivalent to main.js) auth0.js
import { boot } from 'quasar/wrappers'
import { createAuth0 } from '@auth0/auth0-vue'
let auth0 = createAuth0({
domain: "ksadhkajshds",
client_id: "askasahsaksj",
redirect_uri: window.location.origin,
})
export default boot(({ app }) => {
app.config.globalProperties.$auth0 = auth0
})
export { auth0 }
quasar.config.js
I added the bootfile to my config
// code omitted
boot: [
'auth0',
'axios',
],
// code omitted
Hey there!
In order to handle that most effectively can I ask you to raise it as a GitHub issue in the quickstart repo so we can work on that directly with the repo maintainers? Once you have a link to it you can share it here so I can ping them. Thank you!
I already raised an issue but I might have opened it at the wrong repository. Do I just paste the link there or copy it entirely?
opened 09:51AM - 27 Apr 22 UTC
closed 12:48PM - 27 Apr 22 UTC
bug report
### Describe the problem
I cannot log in using the auth0 plugin in my Quasar … project. I am following the [Quick Start page for Vue](https://auth0.com/docs/quickstart/spa/vuejs/01-login#add-login-to-your-application)
<br>
### What was the expected behavior?
After completing the [Add Plugin Using the Options API](https://auth0.com/docs/quickstart/spa/vuejs/01-login#using-the-options-api) part of the quick-start page, I should be able to access the auth0 login page.
<br>
### Reproduction
- **Step 1:** install quasar cli `npm i -g @quasar/cli`
- create quasar project `npm init quasar`
- **Step 2:** follow configuration steps in the [auth0 quick-start page](https://auth0.com/docs/quickstart/spa/vuejs/01-login#using-the-options-api) and create a generic SPA in the Auth0 dashboard
- **Step 3:** install sdk `npm install @auth0/auth0-vue`
- **Step 4:** register the plugin (in a quasar project), following the [quasar guide](https://quasar.dev/quasar-cli-webpack/boot-files#usage-of-boot-files)
- generate quasar boot file `quasar new boot auth0`
- modify the generated boot file `src/boot/auth0.js` file to:
- ```javascript
import { boot } from 'quasar/wrappers'
import { createAuth0 } from '@auth0/auth0-vue'
// "async" is optional;
// more info on params: https://v2.quasar.dev/quasar-cli/boot-files
export default boot(async ( { app } ) => {
app.config.globalProperties.$auth0 = createAuth0({
domain: "<domain_here>",
client_id: "<client_id_here>",
redirect_uri: window.location.origin,
})
})
```
- reference the bootfile in `quasar.config.js`
- ```javascript
boot: [
'auth0',
'axios',
],
```
-
- **Step 5:** add login to app **using the options api**
- modify main layout to include a login button:
- ```javascript
<q-toolbar-title>
Quasar App
</q-toolbar-title>
<div><button @click="login">Log in</button></div>
<div>Quasar v{{ $q.version }}</div>
```
- add login method
- ```javascript
export default defineComponent({
name: 'MainLayout',
components: {
EssentialLink
},
methods: {
login () {
this.$auth0.loginWithRedirect();
}
},
setup () {
const leftDrawerOpen = ref(false)
return {
essentialLinks: linksList,
leftDrawerOpen,
toggleLeftDrawer () {
leftDrawerOpen.value = !leftDrawerOpen.value
}
}
}
})
```
- **Step 6:** run the app `quasar dev` and press the login button
<br>
### Environment
- **Version of `auth0-vue` used:** @auth0/auth0-vue@1.0.0
- **Version of `vue` used: **vue@3.2.33
- **Which browsers have you tested in?** Chrome, Firefox
- **Other modules/plugins/libraries that might be involved:** Quasar CLI
1 Like
No that’s fine! I’m gonna ping the repo maintainers in a few minutes.
1 Like