-
Notifications
You must be signed in to change notification settings - Fork 117
Error authenticating! Error: Token provided to verifyJWT is missing or not a string ? #584
Comments
What is the |
This is my route post where i will verify authenticate . I feel i did an big mistake |
I meant the entire application setup. The minimum complete amount of code we need to reproduce your issue. |
server.js var Users=[
{_id:"1",email:"k0",password:"kk"},
{_id:"2",email:"k1",password:"kk"},
{_id:"3",email:"k2",password:"kk"},
{_id:"4",email:"k3",password:"kk"},
{_id:"5",email:"k4",password:"kk"}];
const feathers = require('feathers');
const bodyParser = require('body-parser');
const errors = require('feathers-errors');
const errorHandler = require('feathers-errors/handler');
const rest = require('feathers-rest');
const hooks = require('feathers-hooks');
const auth = require('feathers-authentication');
const local = require('feathers-authentication-local');
const memory = require('feathers-memory');
const jwt = require('feathers-authentication-jwt');
const app = feathers();
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: true }));
var cors = require('cors');
var port= process.env.PORT || 4200;
app.use(cors());
app.configure(rest())
.configure(hooks())
.use(bodyParser.json())
.use(bodyParser.urlencoded({ extended: true }))
.configure(auth({ secret: 'supersecret' }))
.configure(jwt())
.configure(local())
//.use('/users', memory());
.use('/users', {
find(params) {
return Promise.resolve(Users);
}
})
.use(errorHandler());
app.service('authentication').hooks({
before: {
create: [
auth.hooks.authenticate('local'),
customizeJWTPayload()
],
remove: [
auth.hooks.authenticate('jwt')
]
}
});
app.service('users').hooks({
before: {
create: [
local.hooks.hashPassword({ passwordField: 'password' })
]
}
});
/////////////////
app.post('/#', auth.express.authenticate('local', { successRedirect: '/app', failureRedirect: '/#' }));
app.get('/app', (req, res, next) => {
res.json({ success: true });
});
app.get('/#', (req, res, next) => {
res.json({ success: "faux" });
});
app.listen(port); |
@daffl the error in the route |
in my login.js |
@kilaniba You can put your code between ``` to make it clearer, if you wish. |
@bertho-zero
|
Going to close this since I think we solved it in feathersjs-ecosystem/authentication-local#36 |
I work with reactjs frontend. After create my server.js (feathers ) , i try to send my (username and password) to my route post . there is my code .
When i click my button , there is my error in console "Error authenticating! Error: Token provided to verifyJWT is missing or not a string".
The text was updated successfully, but these errors were encountered: