美文网首页
Client Secret

Client Secret

作者: 海是天空蓝 | 来源:发表于2022-06-09 10:34 被阅读0次

首先准备材料

image image image

下载key文件后要注意保留下来,只能下载唯一一次

现在有这些东西就可以开始配置client_secret.

1.首先要安装ruby

这里放个网址,大家按照步骤就可以了
https://www.jianshu.com/p/c073e6fc01f5

2.开始创建文件

创建文件所在的文件夹
cd '文件夹路径'
touch secret_gen.rb
这个步骤完成后就可以看到文件夹有个文件,点击进去

require "jwt"

key_file = "Path to the private key"
team_id = "Your Team ID"
client_id = "Your App Bundle ID"
key_id = "The Key ID of the private key"
validity_period = 180 # In days. Max 180 (6 months) according to Apple docs.

private_key = OpenSSL::PKey::EC.new IO.read key_file

token = JWT.encode(
{
iss: team_id,
iat: Time.now.to_i,
exp: Time.now.to_i + 86400 * validity_period,
aud: "https://appleid.apple.com",
sub: client_id
},
private_key,
"ES256",
header_fields=
{
kid: key_id
}
)
puts token

把代码粘上去

继续终端步骤
ruby secret_gen.rb

此时就生成了 client_secret

如果有关于如何与后台交互的小伙伴可以评论联系我哦!

require "jwt"
key_file = "xxxxx.p8" #从Developer Center后台下载的key(p8后缀的文件)
team_id = "xxxxxx" #开发者账号的teamID
client_id = "com.xxx.xxx" #应用的BundleID
key_id = "xxxxxx" #从Developer Center后台key_id
validity_period = 180 #有效期

private_key = OpenSSL::PKey::EC.new IO.read key_file

token = JWT.encode(
{
iss: team_id,
iat: Time.now.to_i,
exp: Time.now.to_i + 86400 * validity_period,
aud: "https://appleid.apple.com",
sub: client_id
},
private_key,
"ES256",
header_fields=
{
kid: key_id
}
)
puts token
作者:大佬papp
链接:https://www.jianshu.com/p/cbcb79067451
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

相关文章

网友评论

      本文标题:Client Secret

      本文链接:https://www.haomeiwen.com/subject/syfmmrtx.html