使用UpgradableApp API时“401 Unauthorized”

时间:2014-08-28 18:45:19

标签: ruby google-apps-marketplace

我们正在使用我们的迁移工具将现有的GAMv1用户带到GAMv2,我们正在获取 401未经授权,报告我们的消费者密钥无效。

我们正在使用Google的APIClient ruby​​库,可在此处找到:https://github.com/google/google-api-ruby-client/ 我很确定我们正在转发https://developers.google.com/apps-marketplace/v1migratev2中标识的同一组凭据, 我们正在为API指定两条腿的OAuth 1.0。我们正在使用的代码如下,剥离 只是授权位:

@client = Google::APIClient.new(
    :authorization => :two_legged_oauth_1,
    :application_name => 'App Name',
    :application_version => ‘1.0'
)

@client.authorization.client_credential_key = '%s.apps.googleusercontent.com' % Auth::Application::CONFIG['GOOGLE_GAMV1_APPLICATION_ID']
@client.authorization.client_credential_secret = Auth::Application::CONFIG['GOOGLE_GAMV1_SECRET']
@service = @client.discovered_api('appsmarket', 'v2’)

request = @client.execute(
    @service.upgradable_app.update,
    'marketplaceListingId' => Auth::Application::CONFIG['GOOGLE_GAMV1_LISTING_ID'],
    'domainName' => account.domain,
    'cwsItemId' => Auth::Application::CONFIG['GOOGLE_GAMV2_CWS_ID']
)

查看我们收到的日志(我已经删除了私人详细信息,但我们几乎可以肯定我们已经获得了正确的client_id,client_secret,列表ID等):< / p>

D, [2014-08-28T14:37:17.025667 #12517] DEBUG -- : Google::APIClient - Initializing client with options {:authorization=>:two_legged_oauth_1, :application_name=>"App Name", :application_version=>"1.0"}
D, [2014-08-28T14:37:17.040994 #12517] DEBUG -- : Google::APIClient::Request Sending API request get https://www.googleapis.com/discovery/v1/apis/appsmarket/v2/rest {"User-Agent"=>"App Name/1.0 google-api-ruby-client/0.7.1 Linux/2.6.18-371.3.1.el5\n (gzip)", "Accept-Encoding"=>"gzip", "Content-Type"=>""}
D, [2014-08-28T14:37:17.202238 #12517] DEBUG -- : Decompressing gzip encoded response (2427 bytes)
D, [2014-08-28T14:37:17.202646 #12517] DEBUG -- : Decompressed (11988 bytes)
D, [2014-08-28T14:37:17.202801 #12517] DEBUG -- : Google::APIClient::Request Result: 200 {"expires"=>"Thu, 28 Aug 2014 18:42:17 GMT", "date"=>"Thu, 28 Aug 2014 18:37:17 GMT", "cache-control"=>"public, max-age=300, must-revalidate, no-transform", "etag"=>"\"FrPV2U6xXFUq8eRv_PO3IoAURkc/cQQHsn4vhpzWbmwcoTBTIElFFgs\"", "content-type"=>"application/json; charset=UTF-8", "x-content-type-options"=>"nosniff", "x-frame-options"=>"SAMEORIGIN", "x-xss-protection"=>"1; mode=block", "content-length"=>"2427", "server"=>"GSE", "alternate-protocol"=>"443:quic", "connection"=>"close"}
D, [2014-08-28T14:37:17.326157 #12517] DEBUG -- : Google::APIClient::Request Sending API request put https://www.googleapis.com/appsmarket/v2/upgradableApp/xxxxxxxxxxxx/xxxxxxxxxxxxxxxx/xxxxxxxx {"User-Agent"=>"App Name/1.0 google-api-ruby-client/0.7.1 Linux/2.6.18-371.3.1.el5\n (gzip)", "Accept-Encoding"=>"gzip", "Content-Type"=>"", "Authorization"=>"OAuth oauth_consumer_key=\"xxxxxxxxxx.apps.googleusercontent.com\", oauth_signature_method=\"HMAC-SHA1\", oauth_timestamp=\"xxxxxxxxx\", oauth_nonce=\"xxxxxxxxxxxxxxxxxxxxxxxx\", oauth_version=\"1.0\", oauth_signature=\"xxxxxxxxxxxxxxxxxxx\"", "Cache-Control"=>"no-store"}
D, [2014-08-28T14:37:17.742199 #12517] DEBUG -- : Decompressing gzip encoded response (149 bytes)
D, [2014-08-28T14:37:17.742494 #12517] DEBUG -- : Decompressed (203 bytes)
D, [2014-08-28T14:37:17.742686 #12517] DEBUG -- : Google::APIClient::Request Result: 401 {"www-authenticate"=>"Bearer realm=\"https://accounts.google.com/AuthSubRequest\"", "content-type"=>"application/json; charset=UTF-8", "date"=>"Thu, 28 Aug 2014 18:37:18 GMT", "expires"=>"Thu, 28 Aug 2014 18:37:18 GMT", "cache-control"=>"private, max-age=0", "x-content-type-options"=>"nosniff", "x-frame-options"=>"SAMEORIGIN", "x-xss-protection"=>"1; mode=block", "server"=>"GSE", "alternate-protocol"=>"443:quic", "connection"=>"close", "transfer-encoding"=>"chunked"}
E, [2014-08-28T14:37:17.755822 #12517] ERROR -- : Bad request: status=401, body={"error":{"errors":[{"domain":"global","reason":"authError","message":"Invalid OAuth consumer key","locationType":"header","location":"Authorization"}],"code":401,"message":"Invalid OAuth consumer key"}}

坦率地说,在这一点上,我们开始怀疑这个问题是在供应商的最后 - 但我们很乐意被证明是错的!

1 个答案:

答案 0 :(得分:0)

确认这是谷歌方面的一个错误,已经修复了。谢谢!

相关问题