亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

DocuSign JWT 響應錯誤 invalid_request 使用 PHP

DocuSign JWT 響應錯誤 invalid_request 使用 PHP

PHP
人到中年有點甜 2023-06-18 16:24:37
我在嘗試從 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 回答

?
幕布斯7119047

TA貢獻1794條經驗 獲得超8個贊

請考慮使用 SDK 而不要嘗試自己進行 JWT 編碼。它將使它更容易、更安全,并最終為您啟用其他功能。


查看完整回答
反對 回復 2023-06-18
?
隔江千里

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), '+/', '-_'));



查看完整回答
反對 回復 2023-06-18
  • 2 回答
  • 0 關注
  • 185 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號