我在嘗試從 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 responseif ( $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 或者知道我可能做錯了什么?
2 回答

隔江千里
TA貢獻1906條經驗 獲得超10個贊
我相信你想更換你的臺詞:
? ? $header = urlencode( base64_encode( json_encode( $header ) ) );
? ? $body = urlencode( base64_encode( json_encode( $body ) ) );
和
? ? $header = str_replace('=', '', strtr(base64_encode($header ), '+/', '-_'));
? ? $body = str_replace('=', '', strtr(base64_encode($body), '+/', '-_'));
與您的簽名相同:
? ? $signature = str_replace('=', '', strtr(base64_encode($signature), '+/', '-_'));
- 2 回答
- 0 關注
- 185 瀏覽
添加回答
舉報
0/150
提交
取消