【发布时间】:2022-11-10 08:20:32
【问题描述】:
我正在使用 ruby 库 google-api-ruby-client 的 play integrity 解密和 google-apis-playintegrity_v1 Android 结果,但它返回 400 错误。
我试图通过参考this article等找到问题的原因。 我想听听你的建议。
正在实现的源代码如下
# Gemfile
gem "google-apis-playintegrity_v1"
...
# API executable file
require 'google/apis/playintegrity_v1'
class AndroidRightfulnessCheck
class << self
def device_rightfulness_check( integrity_token: token)
play_integrity = Google::Apis::PlayintegrityV1
decode_integrity_token_request = play_integrity::DecodeIntegrityTokenRequest.new
play_integrity_service = play_integrity::PlayIntegrityService.new
cred = Google::Auth::DefaultCredentials.make_creds(json_key_io: StringIO.new(ENV["PRIVATE_KEY"]), scope: "https://www.googleapis.com/auth/playintegrity")
play_integrity_service.authorization = cred
integrity_token = decode_integrity_token_request.update!(integrity_token: integrity_token)
payload = play_integrity_service.decode_integrity_token(package_name, integrity_token)
end
end
end
结果
Error - #<Google::Apis::ClientError: Invalid request status_code: 400 header: #<HTTP::Message::Headers:0x000055d11d04b098 @http_version="1.1"
, @body_size=0
, @chunked=false
, @request_method="POST"
, @request_uri=#<Addressable::URI:0x2ae88e7fa714 URI:https://playintegrity.googleapis.com/v1/package_name:decodeIntegrityToken?>
, @request_query=nil
, @request_absolute_uri=nil
, @status_code=400
, @reason_phrase="Bad Request"
, @body_type=nil
, @body_charset=nil
, @body_date=nil
, @body_encoding=#<Encoding:UTF-8>
, @is_request=false
...
body: "{\n \"error\": {\n \"code\": 400
,\n \"message\": \"Integrity token cannot be decoded due to invalid arguments.\"
,\n \"status\": \"INVALID_ARGUMENT\"\n }\n}\n">
参考文件
https://www.rubydoc.info/gems/google-apis-playintegrity_v1/0.5.0/Google/Apis/PlayintegrityV1/PlayIntegrityService https://www.rubydoc.info/gems/google-apis-playintegrity_v1/0.5.0/Google/Apis/PlayintegrityV1/DecodeIntegrityTokenRequest
【问题讨论】:
-
您传递给 API 的包名称是否与生成的完整性令牌相同?
标签: ruby-on-rails ruby google-api google-play-services google-play-developer-api