Reputation: 833
I'm trying to set up my first vue.js 2 app with Auth0. The API part works fine, but I'm getting errors in webpack related to the auth service described in the auth0 quickstart here: https://auth0.com/docs/quickstart/spa/vuejs
Module parse failed: Unexpected token (18:8)
You may need an appropriate loader to handle this file type.
| }
|
| auth0 = new auth0.WebAuth({
I don't really understand the syntax being used in this class, since auth0 is the name used in the import statement. My application is a standard vue.js scaffold generated app with webpack.
Here is the whole .js from the quickstart:
import auth0 from 'auth0-js'
import { AUTH_CONFIG } from './auth0-variables'
import EventEmitter from 'eventemitter3'
import router from './../router'
export default class AuthService {
constructor () {
this.login = this.login.bind(this)
this.setSession = this.setSession.bind(this)
this.logout = this.logout.bind(this)
this.isAuthenticated = this.isAuthenticated.bind(this)
}
auth0 = new auth0.WebAuth({
domain: 'omitted',
clientID: 'omitted',
redirectUri: 'http://localhost:3000/callback',
audience: 'omitted',
responseType: 'token id_token',
scope: 'openid'
})
login () {
this.auth0.authorize()
}
}
Upvotes: 1
Views: 188
Reputation: 162
I had the same problem. Turns out the auth0 examples are not compatible with the most recent vue version. This github repo seemed to do the trick for me: https://github.com/DominikAngerer/auth0-vue
Upvotes: 1