fixed bot安装仓库列表必须使用access_tokens获取到bot的token才能查询

This commit is contained in:
2023-04-04 17:38:48 +08:00
parent 04c30be5a6
commit 80fa5330b2
3 changed files with 71 additions and 25 deletions

32
test/jwt_github_test.rb Normal file
View File

@@ -0,0 +1,32 @@
require 'openssl'
require 'jwt' # https://rubygems.org/gems/jwt
# Private key contents
private_pem = File.read("/Users/xxq/Documents/gitlink-webhook.2022-06-09.private-key.pem")
private_key = OpenSSL::PKey::RSA.new(private_pem)
# Generate the JWT
payload = {
# issued at time, 60 seconds in the past to allow for clock drift
iat: Time.now.to_i - 60,
# JWT expiration time (10 minute maximum)
exp: Time.now.to_i + (10 * 60),
# GitHub App's identifier
iss: "209248"
}
jwt = JWT.encode(payload, private_key, "RS256")
puts jwt
# puts OpenSSL::PKey::RSA.new(private_key33).public_key.to_s
#
# rsa_private = OpenSSL::PKey::RSA.new(private_key33)
# rsa_public = rsa_private.public_key
#
#
# puts decoded_token[0]
# puts decoded_token[0]["iss"]
# serialized_private_key = OpenSSL::PKey::RSA::generate(2048).to_s