相关疑难解决方法(0)

JWT 计算签名 SHA256withRSA

我试图

使用从 API 控制台获取的私钥,使用 SHA256withRSA(也称为 RSASSA-PKCS1-V1_5-SIGN 和 SHA-256 哈希函数)对输入的 UTF-8 表示进行签名。输出将是一个字节数组。

所以让我们把 Header 和 Claim 设置成数组

{"alg":"RS256","typ":"JWT"}.
{
  "iss":"761326798069-r5mljlln1rd4lrbhg75efgigp36m78j5@developer.gserviceaccount.com",
  "scope":"https://www.googleapis.com/auth/prediction",
  "aud":"https://accounts.google.com/o/oauth2/token",
  "exp":1328554385,
  "iat":1328550785
}
Run Code Online (Sandbox Code Playgroud)

就像服务帐户:计算签名

JSON Web 签名 (JWS) 是指导为 JWT 生成签名的机制的规范。签名的输入是以下内容的字节数组

{ Base64url 编码的标头}.{ Base64url 编码的声明集}

所以我构建数组只是为了测试

  $seg0 = array(
    "alg" => "RS256",
    "typ" => "JWT"
  );
  $seg1 = array(
    "iss" => "761326798069-r5mljlln1rd4lrbhg75efgigp36m78j5@developer.gserviceaccount.com",
    "scope" => "https://www.googleapis.com/auth/prediction",
    "aud" => "https://accounts.google.com/o/oauth2/token",
    "exp" => 1328554385,
    "iat" => 1328550785
  );

  $segs = array(
    json_encode($seg0),
    stripslashes(json_encode($seg1))
  ); …
Run Code Online (Sandbox Code Playgroud)

php oauth-2.0

5
推荐指数
1
解决办法
2432
查看次数

标签 统计

oauth-2.0 ×1

php ×1