我目前正在为我的Chatkit API验证通过Koa,Koa-bodyparser和Koa-router创建的用户。我来自localhost:8080 / auth的AuthenticationResponse是:
AuthenticationResponse {
status: 200,
headers: {},
body: {
access_token: 'MY_ACCESS_TOKEN',
expires_in: 86400,
token_type: 'bearer'
}
}
但这是我从客户那里得到的答复。 “无法解析令牌” statusCode:401 标头:{Request-Method:“ SUBSCRIBE”} 错误:“身份验证/ jwt /无效”
我的身份验证POST请求是:
router.post('/auth', authenticateUser);
async function authenticateUser(ctx,next){
try{
const {grant_type} = ctx.request.body;
const authdata = chatkit.authenticate({grant_type, userId: ctx.request.query.user_id});
console.log(authdata);
}catch(err){
console.log(err.message)
}
next();
}
我认为这与不将其作为JSON Web令牌发送有关,因为我没有使用Express(res.json),所以如果有人能给我一些指导,因为我对这一切还不陌生!