Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auth0 audience parameter is missing #176

Closed
vladimir-chernenko opened this issue May 13, 2018 · 3 comments · Fixed by #222
Closed

Auth0 audience parameter is missing #176

vladimir-chernenko opened this issue May 13, 2018 · 3 comments · Fixed by #222
Labels

Comments

@vladimir-chernenko
Copy link

Reproduction link

https://auth0.com/docs/api-auth/tutorials/client-credentials#ask-for-a-token

Steps to reproduce

Hi, I'm using this module for authorization to my django rest api. At the beginning I was getting back strange short Bearer token without API access.
Then I understood that the audience parameter is missing on login redirect.

https://github.com/nuxt-community/auth-module/blob/dev/lib/schemes/oauth2.js#L47

What is expected ?

May be options should be updatable?
Or how I can extend auth module to custom login function?

What is actually happening?

Unauthorised access to API

This bug report is available on Nuxt.js community (#c134)
@ghost ghost added the cmty:bug-report label May 13, 2018
@chrpeters
Copy link

I am experiencing the same problem. Also I think for auth0, the client_id parameter has to be named client

@vladimir-chernenko
Copy link
Author

When I've tried to extend oauth2 strategy I've got an error:

import Oauth2Scheme from '@nuxtjs/auth/lib/schemes/oauth2'


export default class Auth0Scheme extends Oauth2Scheme {
  login () {
    const opts = {
      protocol: 'oauth2',
      response_type: this.options.response_type,
      client_id: this.options.client_id,
      redirect_uri: this._redirectURI,
      scope: this._scope,
      audience: this.options.audience,
      state: btoa(Math.random() + '').replace('==', '')
    }

    this.$auth.$storage.setLocalStorage(this.name + '.state', opts.state)

    const url = this.options.authorization_endpoint + '?' + encodeQuery(opts)

    window.location = url
  }
}

The error:

ERROR  Failed to compile with 1 errors 8:55:46 PM

This relative module was not found:
* ../utilities in ./node_modules/@nuxtjs/auth/lib/schemes/oauth2.js

@chrpeters
Copy link

Tried this as well and the problem is, that the module cleans up the files and copies only the schemes that are needed. So when using the new auth0Scheme, the oauth2Scheme ist not copied anymore. After adding a strategy that uses oauth2 to the list of strategies ( like github: { }) in nuxt.config.js, it worked.

after that i got an error, that the parseQuery method could not be found, so i included the imports from the oauth2scheme into the auth0scheme as well:
import { encodeQuery, parseQuery, randomString } from '../utilities'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants