我正在尝试使用Servicestack JsonServiceClient连接到JWT身份验证服务,但Docs仅描述了如何使用C#客户端执行此操作:
http://docs.servicestack.net/jwt-authprovider
在这些文档中,它表明客户端上应该有BearerToken属性,如下所示:
var jwtToken = this.auth.getAccessToken();
this.client = new JsonServiceClient('/');
// Variation #1
this.client.headers.append("Authentication" , jwtToken,);
// Variation #2
this.client.headers.append("Authentication" , "Bearer " + jwtToken,);
// Variation #3
this.client.headers.append("Authentication" , "BearerToken " + jwtToken,);
然而,这似乎在Javascript客户端上丢失了。如何在使用Javascript客户端时分配jwtToken?
我尝试了以下变体来实现此功能:
logging.error('TYPEOF: %s', type(self.db_engine))
logging.error('CREATE 1')
with self.db_engine.connect() as connection:
table_sql_create = CreateTable(MyTmpModel.__table__)
connection.execute(table_sql_create)
logging.error('CREATE 2')
with self.db_engine.connect() as connection:
table_sql_create = CreateTable(MyTmpModel.__table__)
connection.execute(table_sql_create)
logging.error('SUCCESS')
答案 0 :(得分:3)
胜利!
我的错误是标题名称。它不是“身份验证”,而是“授权”。
这样可行:
this.client.headers.append("Authorization" , "Bearer " + jwtToken,);