我正在使用http://jwt.io网站中提供的jose库,正在尝试使用此库创建jwt令牌,但是在粘贴到http://jwt.io网站中以及尝试使用curl apple开发人员时,生成的令牌会显示无效签名连接401未经授权的响应!我不知道是什么原因造成的。
class Math:
def __init__(self, number):
self.number = number
def add(self, add_num):
self.number += add_num
return self
# or:
# return Math(self.number + add_num)
def sub(self, sub_num):
self.number -= sub_num
return self
# or:
# return Math(self.number - add_num)
def __str__(self):
return str(self.number)
m = Math(5).add(5).sub(3)
print(m)
# 7
curl -v -H'授权:承载[签名令牌]' “ https://api.appstoreconnect.apple.com/v1/apps”
答案 0 :(得分:0)
我对库不熟悉,但是似乎您每次运行代码时都使用随机生成的新密钥对令牌进行签名:
EllipticCurveJsonWebKey senderJwk = EcJwkGenerator.generateJwk(EllipticCurves.P256);
您似乎也将密钥ID设置为以base-64编码的私钥(也许是您打算使用的私钥?)。密钥ID不是密钥,它只是可用于在密钥存储库中查找的内容,例如(According to Apple,其API的密钥ID应为“您在App Store中的私钥ID连接”)。
因此,我猜想您收到“无效签名”错误的原因是因为您每次都使用新密钥对令牌进行签名,而不是用于验证令牌的密钥。