Closed joshuaebowling closed 4 years ago
The error you're getting indicates that the token that you're creating and passing to your API is missing an aud
claim. I don't see any code here generating a token— can you share or check the code responsible for generating a token and confirm that it includes aud
in its payload?
@devinivy I think you are correct.
login: {
method: 'POST',
path: '/login',
options: {
auth: false,
validate: {
payload: Joi.object(Domain.Login(Joi)),
failAction
}
},
handler: async (request, h, err) => {
var result = await UserService.login(request.payload);
var token = "";
if(result.Data) {
token = Jwt.token.generate({test: 'ok'}, secret);
}
return { user: result, token};
}
},
I didn't see any parameter in Jwt.token.generate()
for aud
. I imagined that it used the 'aud' prop from the initial configuration.
Great, sounds like this is resolved! If there's an improvement to the docs to be made (and I'm sure there is!), a PR would certainly be welcome.
@devinivy I'm still getting the same error. But I'm definitely not afraid to dig in and see where I'm going wrong. If I think my findings are of value, I'll certainly create a PR.
Ah, sorry I missed that you were having troubling including the aud
claim. It can go right in the payload passed to generate()
, e.g. Jwt.token.generate({ aud: 'urn:audience:test', test: 'ok' }, secret)
.
@devinivy I had used aud I am also still getting the same error I found this helpful, its worked for me https://github.com/hapijs/jwt/issues/15#issuecomment-683755670
Context
How can we help?
sending request with generated token returns the following error:
Here's my init (ripped from api.md)
Additionally, I've tried to set an "aud" property in headers as well as body that match the value in the above code.
Any ideas how I can resolve?
thanks!