我正在尝试使用Docusign JWT身份验证获取访问令牌,但我始终获得:
{"error":"invalid_grant","error_description":"unsupported_grant_type"}
我仔细检查了所有数据(集成密钥、api用户名等),它们都很好。我遵循了Docusign指南中的所有步骤。
我唯一不能100%确定的部分是何时生成JWT令牌的签名。文件说:
The first two parts of the JWT are signed with your application's private key (using the RSA SHA-256 digital signature algorithm) as shown in the diagram.
这是我生成签名的方式:
$header = [
'typ' => 'JWT',
'alg' => 'RS256'
];
$body = [
'iss' => getenv('INTEGRATION_KEY'),
'sub' => getenv('API_USERNAME'),
'iat' => time(),
'exp' => time() + 3600,
'aud' => str_replace('https://', '', getenv('AUTH_URL')),
'scope' => 'signature impersonation'
];
$signature = JWT::encode($body, file_get_contents(env('PRIVATE_KEY')), 'RS256');
$header = $this->base64url_encode(json_encode($header));
$body = $this->base64url_encode(json_encode($body));
$jwt = $header . '.' . $body . '.' . $signature;
那是正确的吗?如果没有,因为JWT::encode期望数组作为第一个参数,我应该怎么做才能让它工作?
这就是我请求访问令牌的方式:
return Http::withHeaders(
[
'Content-Type' => 'application/x-www-form-urlencoded'
]
)->post(
getenv('AUTH_URL') . '/oauth/token',
[
'grant_type' => 'urn:ietf:params:oauth:grant-type:jwt-bearer',
'assertion' => $jwt
]
);
谢谢
我在使用Laravel 6的应用程序中遇到了相同的问题,我设法解决了它,如下所示:
// the Header will not be needed as it is automatically generated
$header = [
'typ' => 'JWT',
'alg' => 'RS256'
];
$body = [
'iss' => getenv('INTEGRATION_KEY'),
'sub' => getenv('API_USERNAME'),
'iat' => time(),
'exp' => time() + 3600,
'aud' => str_replace('https://', '', getenv('AUTH_URL')),
'scope' =>'signature impersonation'
];
/**
* Note that when creating the JWT, only the $body is provided,
* as the function already performs the necessary concatenations.
* in your code you put it like this:
* $jwt = $header . '.' . $body . '.' . $signature;
* which generates a hash that cannot be validated,
*/
// create the JWT
$jwt = JWT::encode($body , $privateKey, 'RS256');
// make the request
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', getenv('AUTH_URL').'/oauth/token',['query' =>[
'grant_type' => 'urn:ietf:params:oauth:grant-type:jwt-bearer',
'assertion' => $jwt,
]
]);
echo '<pre>';
print_r($response);
echo '</pre>';
创建正确的JWT令牌很困难。我建议您使用PHPSDK中的requestJWTUserToken,或者查看其源代码以了解它是如何发出OAuth请求的。
显然Firebase JWT编码方法没有以正确的方式对字符串进行编码。
我用了这个:
$header = $this->base64url_encode(json_encode($header));
$body = $this->base64url_encode(json_encode($body));
openssl_sign(
$header.".".$body,
$signature,
file_get_contents(env('PRIVATE_KEY_PATH')),
"sha256WithRSAEncryption"
);
而且奏效了。
请确保在请求同意和请求jwt令牌时使用相同的作用域。
谢谢大家的帮助。
我正在尝试使用spotipy向特定用户验证我的python应用程序。我以前和其他一些用户做过这件事,没有任何问题。然而,每当我尝试使用这个用户时,我总是得到“{”错误“:“无效的授权”,“错误描述“:“无效的授权码”}” 我还尝试了几种手动方式,包括卷曲: curl-H“授权:基本OTQxNDliNjI3…WRhMzk5YTY2ZTliZWY=“-d授权类型=授权代码-d代码=AQByvdq4Vr
我遇到了使用文档签名 API 的第一个障碍,需要一些帮助。 我将docusignrestapi集合导入到Postman中。我设置了iKey、iSec、encodedKeys和codeFromUrl变量。 当尝试发送'01-授权代码授予访问令牌'post API时,我每次都得到以下响应。 我尝试从Postman中删除所有内容,包括环境,并从DocuSign中删除该应用程序,然后重新开始,以便我的所有
获取授权token 请求地址 https://api.es.xiaojukeji.com/openauth/Service/getToken 返回数据格式 JSON 请求方式 POST 访问授权限制 暂无 请求参数 名称 类型 必选 描述 out_company_id string yes 待授权公司在平台的id out_company_name string yes 待授权公司在平台的名称 ou
密钥锁留档中写到,令牌endpoint可用于在授权代码流中获取临时代码,或通过隐式流、直接授权或客户端授权获取令牌。 但是即使使用response_type=code,我也无法获得授权码:只能获得令牌。我该怎么做呢? 我的测试请求: 资料来源:https://www.keycloak.org/docs/latest/server_admin/index.html#keycloak-服务器oidc-
获取企业授权 PDF版下载 为了保证信息安全,所有API(包括第三方API及通讯录、发消息等所有API)调用需要验证来源域名。只有在应用开发信息中填写的合法授信域名才能合法调用。 获取第三方应用凭证 该API用于获取第三方应用凭证(suite_access_token)。 由于应用提供商可能托管了大量的企业,其安全问题造成的影响会更加严重,本接口除了合法来源IP校验之外,还额外需要suite_ti
接口说明 获取授权代码 如需调用,请访问 开发者文档 来查看详细的接口使用说明 该接口仅开放给已获取SDK的开发者 API地址 GET /wish3dearth/api/access/v1.0.0/getHardWareCode 是否需要登录 否 请求字段说明 无 响应字段说明 无 响应成功示例 { "code": 0, "data": "134305892", "message":
接口说明 获取授权代码 如需调用,请访问 开发者文档 来查看详细的接口使用说明 该接口仅开放给已获取SDK的开发者 如开启https功能,请求地址的协议应改为https,如:https://www.example.com/wish3dearth/api/access/v1.0.0/getLicenseInfo API地址 GET /wish3dearth/api/access/v1.0.0/get
我使用了以下来自google的示例https://developers.google.com/identity/sign-in/web/server-side-flow到目前为止,我能够实现以下步骤: 用户在客户端(浏览器)进行身份验证。 代码返回并保存在服务器数据库中。 请求身份验证代码令牌时,响应异常:401未授权 我检查了以下内容: 接口已启用 在 https://developers.go