Skip to content
This repository has been archived by the owner on Mar 22, 2022. It is now read-only.

createJWT throws 'secret must provided' #437

Closed
whollacsek opened this issue Mar 7, 2017 · 8 comments
Closed

createJWT throws 'secret must provided' #437

whollacsek opened this issue Mar 7, 2017 · 8 comments

Comments

@whollacsek
Copy link
Contributor

The doc says app.passport.createJWT(payload, options) will pull from config automatically, but I'm getting secret must provided error when calling app.passport.createJWT(payload)

@marshallswain
Copy link
Member

@whollacsek please show your config and let us know the version numbers of the auth plugins used.

@whollacsek
Copy link
Contributor Author

whollacsek commented Mar 8, 2017

Looking at the source code of createJWT (https://github.com/feathersjs/feathers-authentication/blob/master/src/utils.js) the app config is not loaded, so I'm using hook.app.service('authentication').create({}) instead which works.

@Mattchewone
Copy link

@whollacsek You config should look something similar to this:

  "authentication": {
    "secret": "<TOKEN>",
    "strategies": [
      "jwt",
      "local"
    ],
    "path": "/authentication",
    "service": "users"
  },

@whollacsek
Copy link
Contributor Author

@Mattchewone I didn't know it's necessary to setup "strategies": [ "jwt", "local" ] can you point me to the docs about this?

@Mattchewone
Copy link

I may be leading you down the wrong path @whollacsek I was reading the v1 docs - https://github.com/feathersjs/feathers-authentication/tree/master

If you are not using that then you can ignore my comment.

@whollacsek
Copy link
Contributor Author

whollacsek commented Mar 10, 2017

@Mattchewone I'm on v1, but the doc doesn't talk about setting "strategies": [ "jwt", "local" ] in the config files

@Mattchewone
Copy link

@whollacsek The strategies is just a preference for doing this:

const config = app.get('authentication');
auth.hooks.authenticate(config.strategies);

Looking at the authenticate init method strategies are not being used, I guess as each strategy needs to be initialised separately.

Do you have your config and your authenticate configuration?

@daffl
Copy link
Member

daffl commented Mar 10, 2017

The docs are wrong. app.passport.createJWT and app.passport.verifyJWT needs options passed.

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

No branches or pull requests

4 participants