Auth-module: How do I extend OAuth2 Scheme?

Created on 29 Jul 2020  路  6Comments  路  Source: nuxt-community/auth-module

I am trying to create a new scheme that extends off of OAuth2. Like so:

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

export default class newScheme extends OAuth2 {...

I get this error ERROR in ./node_modules/@nuxtjs/auth/lib/schemes/oauth2.js Module not found: Error: Can't resolve '../utilities' in '/Users/afeezawoyemi/workspace/P/logistics-config-ui/node_modules/@nuxtjs/auth/lib/schemes'

It appears the utilities module is indeed not present in the specified relative path, what is the right way to extend OAuth2 scheme?

STEPS TO REPRODUCE

  • create a custom scheme
  • extend OAuth2 scheme like so:
import OAuth2 from '@nuxtjs/auth/lib/schemes/oauth2'

export default class newScheme extends OAuth2 {...
  • attempt to use your new scheme by adding it to nuxt.config.js

WHAT HAPPENS

ERROR in ./node_modules/@nuxtjs/auth/lib/schemes/oauth2.js
Module not found: Error: Can't resolve '../utilities' in '/Users/afeezawoyemi/workspace/P/logistics-config-ui/node_modules/@nuxtjs/auth/lib/schemes'

WHAT SHOULD HAPPEN

New scheme should work without errors

PS:
Thank y'all for your contributions to the Nuxt community.
May be related to #176

Most helpful comment

Digging a little deeper, I see the issue originated from this line on master (which I'm currently using, not the dev branch).

Line one:
import { encodeQuery, parseQuery, addTokenPrefix } from '../utilities'
whereas there's no utilities directory/file in the specified relative path (utilities is defined in lib/core/utilities.js, which doesn't match the specified path).

Seems to work internally and only freaks out when referencing module are exported externally (while attempting to extend oauth2 module in my own case)

All 6 comments

Might be fixed by https://github.com/nuxt-community/auth-module/pull/774? @timrchavez @JoaoPedroAS51

Digging a little deeper, I see the issue originated from this line on master (which I'm currently using, not the dev branch).

Line one:
import { encodeQuery, parseQuery, addTokenPrefix } from '../utilities'
whereas there's no utilities directory/file in the specified relative path (utilities is defined in lib/core/utilities.js, which doesn't match the specified path).

Seems to work internally and only freaks out when referencing module are exported externally (while attempting to extend oauth2 module in my own case)

Bumped into this issue as well. Probably path to methods should be updated to fix the issue

I switched to the dev branch, that solves my issue.
I don't know if it's worth raising a pr to fix this on master? Otherwise, I'm willing to close this since the dev branch is more updated and should fix issues like this mostly.

@damafeez yes, i see they've moved utils to the proper location and it should work there. do you know any ETA when dev would be merged into master?

p.s. i think we can close PR with mark that it's fixed in dev branch for future reference

@gorenburg re ETA, I've been wondering also. master's been behind for so long, I wonder if there's any plan to merge them soon. Anyway, I'll just stick to the dev branch for now.

Closing since issue is already resolved on dev

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DougHayward picture DougHayward  路  4Comments

eatyrghost picture eatyrghost  路  3Comments

DiegoGallegos4 picture DiegoGallegos4  路  3Comments

nikkanetiya picture nikkanetiya  路  3Comments

dasisyouyu picture dasisyouyu  路  3Comments