我在尝试从 DocuSign 检索 JWT 令牌时遇到问题,到目前为止,这是我已完成的代码片段(使用 DEVELOPER SANDBOX 帐户):
// Developer exmple
$header = [
'typ' => 'JWT',
'alg' => 'RS256',
];
$time = time();
$body = [
// Integration key provded by DocuSign at Admin > API and Keys > Apps.
'iss' => '[Integration key]',
// User ID provded by DocuSign at Admin > API and Keys.
'sub' => '[User ID]',
'iat' => $time,
'exp' => strtotime( '+45 minutes', $time ),
'aud' => 'account-d.docusign.com',
'scope' => 'signature impersonation',
];
// RSA Private key provided by DocuSign
// When integration APP was created
$rsa_key = '-----BEGIN RSA PRIVATE KEY----- [.........]';
// Base64 + URL Encoding
$header = urlencode( base64_encode( json_encode( $header ) ) );
$body = urlencode( base64_encode( json_encode( $body ) ) );
// JWT signature created using Firebase\JWT\JWT package
$signature = JWT::encode(
$header . '.' . $body,
$rsa_key,
'RS256'
);
// Get request using Curl (10quality/php-curl package)
$response = curl_request(
'https://account-d.docusign.com/oauth/token',
'POST',
[
'grant_type' => 'urn:ietf:params:oauth:grant-type:jwt-bearer',
'assertion' => $header . '.' . $body . '.' . $signature,
]
);
// Process response
if ( $response ) {
$response = json_decode( $response );
if ( isset( $response->error ) )
throw new Exception( 'DocuSign error: ' . $response->error );
var_dump( $response );
}
这是我遵循的指南: https: //developers.docusign.com/esign-rest-api/guides/authentication/oauth2-jsonwebtoken
根据本指南,抛出的错误表明 JWT 未正确创建,尽管我已多次检查我的代码并且它遵循指南中描述的所有内容。
我有点卡住了,我对我的代码有什么问题一无所知,我什至做了逆向工程来验证编码是否正确。
有没有人以前使用过 DocuSign JWT 或者知道我可能做错了什么?
幕布斯7119047
隔江千里