根据SDK的文档和GitHub存储库,已弃用ConfigureJwtAuthorizationFlow和ConfigureJwtAuthorizationFlowByKey,应使用RequestJWTUserToken。我遵循这些示例,并使用Official NuGet DocuSign 3.0.1.0程序包。即使在存储库中也似乎不存在此方法?应该使用什么?有人建议如何完成此操作吗?
这是我正在使用的示例代码块:
public class DocuSignEmbeddedTest
{
...
public string JWTAuthLogin()
{
// we set the api client in global config when we configured the client
var apiClient = Configuration.Default.ApiClient;
// Get your app specific Uri generated
string oauthLoginUrl = GetAuthorizationURLforConsent();
const string oAuthBasePath = "account-d.docusign.com";
var tokenInfo = apiClient.RequestJWTUserToken(IntegratorKey, UserID, oAuthBasePath, PRIVATE_KEY_BYTES, 1);
var userInfo = apiClient.GetUserInfo(tokenInfo.access_token);
var accountId = string.Empty;
foreach (var item in userInfo.Accounts)
{
if (item.IsDefault == "true")
{
accountId = item.AccountId;
apiClient = new ApiClient(item.BaseUri + "/restapi");
break;
}
}
return accountId;
}
public string GetAuthorizationURLforConsent()
{
// we set the api client in global config when we configured the client
var apiClient = Configuration.Default.ApiClient;
// Give consent to your app
// Adding signature as out scope.
var scopes = new List<string>
{
OAuth.Scope_SIGNATURE,
OAuth.Scope_IMPERSONATION
};
const string redirectUrl = "<url>";
var oauthLoginUrl = apiClient.GetAuthorizationUri(IntegratorKey, scopes, redirectUrl, OAuth.CODE, "test");
return oauthLoginUrl.AbsoluteUri;
}
public void ConfigureApiClient(string basePath)
{
// instantiate a new api client
var apiClient = new ApiClient(basePath);
// set client in global config so we don't need to pass it to each API object.
Configuration.Default.ApiClient = apiClient;
}
}
答案 0 :(得分:0)
RequestJWTUserToken方法接受私钥字节或流。示例代码仍在使用字符串变量。请更新示例代码以使用字节。
//私钥流-在此处添加私钥流 私有只读字符串PRIVATE_KEY_BYTES =“ [PRIVATE_KEY_BYTES]”;
var tokenInfo = apiClient.RequestJWTUserToken(IntegratorKey,UserID,oAuthBasePath,PRIVATE_KEY_BYTES,1);
答案 1 :(得分:-1)
它在当前版本中。参见ApiClient.cs
的第990行