hello!!! I have this middleware on my back:
const { auth } = require("express-oauth2-jwt-bearer");
import { env } from "../../utils/enviroment";
export const validateAccessToken = auth({
issuerBaseURL: `https://${env.AUTH0_DOMAIN}`,
audience: env.AUTH0_AUDIENCE,
})
and I have this middleware too:
//file server.js
app.use(errorHandler);
app.use(notFoundHandler);
following this example:
https://github.com/auth0-developer-hub/api_express_javascript_hello-world
and in my front(Vue js 3) I have:
<template>
<div class="content-layout" :v-if="invalidUser">
<h1 id="page-title" class="content__title">Warning</h1>
<div class="content__body">
<p id="page-description">
<span>You are <strong>Blocked</strong>.</span>
<span><strong >Only authorized users can access this platform.</strong></span>
</p>
<div class="profile-grid" >
<button class="button__cancel" @click="goHome" style="">Go home</button>
</div>
</div>
</div>
</template>
<script>
import { checkUserLogged } from "../services/message.service";
export default {
data() {
return {
user: this.$auth0.user,
invalidUser: false
};
},
computed: {
},
methods: {
async checkUser() {
if(this.user.name){
const accessToken = await this.$auth0.getAccessTokenSilently();
const user = this.user;
const { data, error } = await checkUserLogged(accessToken, user);
if (data) {
if( data.authorize ){
this.$router.push('/profile');
}else{
this.invalidUser = true;
setTimeout(async () => {
await this.$auth0.logout({
logoutParams: {
returnTo: 'http://localhost:4040/',
}
});
}, 5000);
}
}
if (error) {
this.message = JSON.stringify(error, null, 2);
}
}
},
goHome(){
this.$auth0.logout({
logoutParams: {
returnTo: 'http://localhost:4040/',
}
});
this.$router.push('/');
}
},
mounted() {
this.checkUser();
},
};
</script>
I’m getting this issue:
401 Unauthorized
message:"Bad credentials"
I checked my enviroment: CLIENT_ORIGIN_URL, AUTH0_AUDIENCE, AUTH0_DOMAIN, AUTH0_CLIENT_ID and AUTH0_CLIENT_SECRET, in my back and front code, and it’s right, you can help me? what’s wrong