我正在实现自定义JSONWebTokenSerializer。到目前为止,它工作正常,但是我需要启用令牌刷新,但是当我尝试刷新令牌时,出现验证错误pingInterval: 5000,
pingTimeout: 2000,
。检查从io.on('connection', async function(socket){
// Server emits initialization
socket.emit('initialization');
// This is to make sure we have a stable internet connection before
// Client emits initializationAcknowledged
socket.on('initializationAcknowledged', function(){
// Increment the total connected count on Redis by 1 on the user hash.
redisClient.watch(socket.userID, function(err) {
if (err) {
console.log('There was an error while watching the conversation with id', conversations.id);
}
redisClient.multi().hincrby(socket.userID, helper.count, 1).exec(function(err, result) {
if (err) {
console.log('There was an error while executing the multi.');
}
if (result === null) {
console.log('The transaction was not performed since the data was modified by someone else during the transaction and changed.');
}
});
});
});
socket.on('disconnect', function(){
// Decrement on redis
redisClient.watch(socket.userID, function(err) {
if (err) {
console.log('There was an error while watching the conversation with id', conversations[0].id);
}
redisClient.multi().hincrby(socket.userID, helper.count, -1).hset(socket.userID, helper.watching, JSON.stringify([])).exec(function(err, result) {
if (err) {
console.log('There was an error while executing the multi');
}
if (result === null) {
console.log('The transaction was not performed since the data was modified by someone else during the transaction and changed.');
}
});
});
});
返回的有效负载时,没有任何response.content
属性。
tf.image.decode_jpeg
这是我的import numpy as np
import requests
import tensorflow as tf
def read_tensor_from_image_url(url,
input_height=299,
input_width=299,
input_mean=0,
input_std=255):
image_reader = tf.image.decode_jpeg(
requests.get(url).content, channels=3, name="jpeg_reader")
float_caster = tf.cast(image_reader, tf.float32)
dims_expander = tf.expand_dims(float_caster, 0)
resized = tf.image.resize_bilinear(dims_expander, [input_height, input_width])
normalized = tf.divide(tf.subtract(resized, [input_mean]), [input_std])
with tf.Session() as sess:
return sess.run(normalized)
def read_tensor_from_image_file(file_name,
input_height=299,
input_width=299,
input_mean=0,
input_std=255):
input_name = "file_reader"
file_reader = tf.read_file(file_name, input_name)
image_reader = tf.image.decode_jpeg(
file_reader, channels=3, name="jpeg_reader")
float_caster = tf.cast(image_reader, tf.float32)
dims_expander = tf.expand_dims(float_caster, 0)
resized = tf.image.resize_bilinear(dims_expander, [input_height, input_width])
normalized = tf.divide(tf.subtract(resized, [input_mean]), [input_std])
with tf.Session() as sess:
return sess.run(normalized)
local_img = read_tensor_from_image_file(
r'Sample-jpg-image-500kb.jpg'
)
online_img = read_tensor_from_image_url(
r'https://sample-videos.com/img/Sample-jpg-image-500kb.jpg'
)
print(np.all(local_img == online_img))
设置:
public class AuthorizeTokenAttribute : System.Web.Http.AuthorizeAttribute
{
public override void OnAuthorization(HttpActionContext actionContext)
{
SetUserContext(actionContext.Request.GetOwinContext()
}
private bool SetUserIdentity(IOwinContext context)
{
AuthenticationTicket authenticationTicket =
Startup.OAuthBearerAuthenticationOptions.AccessTokenFormat.Unprotect(token);
context.Authentication.User = new System.Security.Claims.ClaimsPrincipal();
context.Authentication.User.AddIdentity(authenticationTicket.Identity);
}
}
答案 0 :(得分:0)
对不起,发现了我的错误。将'JWT_ALLOW_REFRESH': False
更改为'JWT_ALLOW_REFRESH': True,
。现在可以使用