I'm doing an integration with Google Api in Ruby.
I'm using google-api-client gem, but I have some problems with the authorization request.
My Code:
client_secrets = Google::APIClient::ClientSecrets.load('client_secret_xxxx-.apps.googleusercontent.com.json')
auth_client = client_secrets.to_authorization
auth_client.update!(:scope => 'https://www.googleapis.com/auth/content') #its possible pass a url to redirect and we can fetch do token
auth_uri = auth_client.authorization_uri.to_s
p auth_uri
This code returns me the url to the authorization to google shopping api.
After I give permissions, I copy the token for here:
token = 'token'
merchant_id = 'xxx'
list_products_url = "https://www.googleapis.com/content/v2/#{merchant_id}/products?key=#{token}"
response = HTTParty.get(list_products_url)
This returns me a Error message like this:
#<HTTParty::Response:0x7fde5c37b8f0 parsed_response={"error"=>{"errors"=>[{"domain"=>"global", "reason"=>"required", "message"=>"Login Required", "locationType"=>"header", "location"=>"Authorization"}], "code"=>401, "message"=>"Login Required"}}, @response=#<Net::HTTPUnauthorized 401 Unauthorized readbody=true>, @headers={"vary"=>["Origin", "X-Origin"], "www-authenticate"=>["Bearer realm=\"https://accounts.google.com/\""], "content-type"=>["application/json; charset=UTF-8"], "date"=>["Wed, 24 Feb 2016 14:58:17 GMT"], "expires"=>["Wed, 24 Feb 2016 14:58:17 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,p=1"], "alt-svc"=>["quic=\":443\"; ma=2592000; v=\"30,29,28,27,26,25\""], "connection"=>["close"], "transfer-encoding"=>["chunked"]}>
I do not know what I'm doing wrong..
I trying to implement this simple example..
https://developers.google.com/shopping-content/v2/reference/v2/products/list#try-it
Best Regards