0
我目前正在嘗試設置發送對象給谷歌的S2AP。 谷歌建議簽署JWTs像this:用google-auth-library-ruby編碼JWT 0.9+
jwt = {
"iss"=> SERVICE_ACCOUNT_EMAIL_ADDRESS,
"aud" => "google",
"typ" => "savetoandroidpay",
"iat"=> Time.now.utc.to_i,
"payload" => {
"loyaltyObjects" => [], #Loyalty objects
"offerObjects" => [], #Offer objects
"loyaltyClasses" => [], #Loyalty classes
"offerClasses" => [] #Offer classes
},
"origins"=> ['http://baconrista.com', 'https://baconrista.com']
}
private_key = Google::APIClient::PKCS12.load_key(SERVICE_ACCOUNT_PRIVATE_KEY, 'notasecret')
jwtEncoded = JWT.encode(jwt, private_key, "RS256")
然而,由於0.8不再是標準,而不再支持Google::APIClient
,我無法找出如何簽署JWT與來自計算所提供的JSON文件引擎服務帳戶。
我目前已經設置了所有其他設置,以生成訪問令牌來與使用OAuth2身份驗證的Google API進行對話,但無法讓我終身瞭解如何對這些JWT進行編碼。
供參考,這是你如何從谷歌獲得訪問令牌與紅寶石gem
compute = Google::Apis::ComputeV1::ComputeService.new
File.open(CONFIG[:GOOGLE_APPLICATION_CREDENTIALS], "r") do |json_io|
compute.authorization = Google::Auth::DefaultCredentials.make_creds(scope: 'https://www.googleapis.com/auth/wallet_object.issuer', json_key_io: json_io)
end
TOKEN = compute.authorization.fetch_access_token!