Auth0 Home Blog Docs

Unexpected Token Error


#1

I have this code from the website, informing me how to setup the WebAuth function of Auth0. I put it in my application and am receiving an unexpected token error on the equals sign that is to the right of the variable weba.

import auth0 from 'auth0-js';

export default class Auth {
  weba = new auth0.WebAuth({
domain: 'bobsburgers.auth0.com',
clientID: 'T6SjpXYPWBvbFwLts3YbXKVQd4gCxUvp',
redirectUri: 'http://localhost:3000/callback',
audience: 'https://bobsburgers.auth0.com/userinfo',
responseType: 'token id_token',
scope: 'openid'
  });

  login() {
this.weba.authorize();
  }
}

I have been debugging for the past hour and haven’t had any understanding of why this error is being thrown. Any thoughts?


#2

:wave: @chasen-bettinger have you previously declared the weba variable? Which website are you referring to? Are you able to share the error message you are receiving?


#3

You’re probably trying to use class fields, which is still in stage 3 proposal, in a browser that doesn’t support it. You need to compile this code a compatible javascript version.

Proposal: https://github.com/tc39/proposal-class-fields
Babel-transform: https://babeljs.io/docs/plugins/transform-class-properties/
Babel-repl: http://babeljs.io/repl/#?babili=false&browsers=&build=&builtIns=false&code_lz=MYGwhgzhAECCCuAXAFtA3gKGtA7gUwCMxoBeaAckTwkXIG4MBfIA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=true&fileSize=false&lineWrap=false&presets=latest%2Cstage-2&prettier=false&targets=&version=6.26.0&envVersion=


#4

This link here: https://manage.auth0.com/#/applications/T6SjpXYPWBvbFwLts3YbXKVQd4gCxUvp/quickstart

Sorry for being ambiguous.

The error message is quite literally:

utils/AuthService.js: Unexpected token (17:7)

 lock = new Auth0Lock(config.AUTH_CONFIG.clientId, config.AUTH_CONFIG.domain, {
      ^

#5

I have since changed it from WebAuth to Auth0Lock. Everything else constant.


#6

Can you follow one of our quickstarts? https://auth0.com/docs/quickstarts

It’s easier if you start with a technology you already know.