{"action":"created","issue":{"url":"https://api.github.com/repos/googleapis/google-api-ruby-client/issues/712","repository_url":"https://api.github.com/repos/googleapis/google-api-ruby-client","labels_url":"https://api.github.com/repos/googleapis/google-api-ruby-client/issues/712/labels{/name}","comments_url":"https://api.github.com/repos/googleapis/google-api-ruby-client/issues/712/comments","events_url":"https://api.github.com/repos/googleapis/google-api-ruby-client/issues/712/events","html_url":"https://github.com/googleapis/google-api-ruby-client/issues/712","id":357346445,"node_id":"MDU6SXNzdWUzNTczNDY0NDU=","number":712,"title":"Caught error Invalid request Error - #<Google::Apis::ClientError: Invalid request>","user":{"login":"andru1989","id":406814,"node_id":"MDQ6VXNlcjQwNjgxNA==","avatar_url":"https://avatars0.githubusercontent.com/u/406814?v=4","gravatar_id":"","url":"https://api.github.com/users/andru1989","html_url":"https://github.com/andru1989","followers_url":"https://api.github.com/users/andru1989/followers","following_url":"https://api.github.com/users/andru1989/following{/other_user}","gists_url":"https://api.github.com/users/andru1989/gists{/gist_id}","starred_url":"https://api.github.com/users/andru1989/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andru1989/subscriptions","organizations_url":"https://api.github.com/users/andru1989/orgs","repos_url":"https://api.github.com/users/andru1989/repos","events_url":"https://api.github.com/users/andru1989/events{/privacy}","received_events_url":"https://api.github.com/users/andru1989/received_events","type":"User","site_admin":false},"labels":[{"id":572338643,"node_id":"MDU6TGFiZWw1NzIzMzg2NDM=","url":"https://api.github.com/repos/googleapis/google-api-ruby-client/labels/type:%20question","name":"type: question","color":"c5def5","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-09-05T18:17:46Z","updated_at":"2018-10-18T22:18:19Z","closed_at":null,"author_association":"NONE","body":"Hi guys I'm trying to list reviews from Google My Business API...\r\nI'm trying to solve this issue in two ways:\r\n\r\n    require 'google/apis/mybusiness_v3'\r\n\r\n    MybusinessV3 = Google::Apis::MybusinessV3\r\n    mybusiness = MybusinessV3::MybusinessService.new\r\n    mybusiness.authorization = Google::Auth::ClientId.new(ENV['GOOGLE_CLIENT_ID'], ENV['GOOGLE_CLIENT_SECRET'])\r\n    mybusiness.list_reviews('Ayenda 1011 Chapinero')\r\n\r\nand \r\n\r\n    require 'googleauth'\r\n    require 'googleauth/stores/redis_token_store'\r\n    require 'google/apis/mybusiness_v3'\r\n\r\n    MybusinessV3 = Google::Apis::MybusinessV3\r\n    mybusiness = MybusinessV3::MybusinessService.new\r\n\r\n    client_id = Google::Auth::ClientId.new(ENV['GOOGLE_CLIENT_ID'], ENV['GOOGLE_CLIENT_SECRET'])\r\n    token_store = Google::Auth::Stores::RedisTokenStore.new(redis: Redis.new)\r\n    scope = \"https://www.googleapis.com/auth/plus.business.manage\"\r\n    authorizer = Google::Auth::WebUserAuthorizer.new(client_id, scope, token_store)\r\n    mybusiness.authorization = authorizer\r\n    mybusiness.list_reviews('Ayenda 1011 Chapinero')\r\n \r\nThe problem is that in both cases I'm getting the following error:\r\n\r\n    Sending HTTP get https://mybusiness.googleapis.com/v3/Ayenda%201011%20Chapinero/reviews?\r\n    404\r\n    #<HTTP::Message:0x007f81cb790780 @http_header=#<HTTP::Message::Headers:0x007f81cb790758 @http_version=\"1.1\", @body_size=0, @chunked=false, @request_method=\"GET\", @request_uri=#<Addressable::URI:0x3fc0e5c5ddd0 URI:https://mybusiness.googleapis.com/v3/Ayenda%201011%20Chapinero/reviews?>, @request_query=nil, @request_absolute_uri=nil, @status_code=404, @reason_phrase=\"Not Found\", @body_type=nil, @body_charset=nil, @body_date=nil, @body_encoding=#<Encoding:UTF-8>, @is_request=false, @header_item=[[\"Date\", \"Tue, 04 Sep 2018 20:26:37 GMT\"], [\"Content-Type\", \"text/html; charset=UTF-8\"], [\"Server\", \"ESF\"], [\"Content-Length\", \"1598\"], [\"X-XSS-Protection\", \"1; mode=block\"], [\"X-Frame-Options\", \"SAMEORIGIN\"], [\"X-Content-Type-Options\", \"nosniff\"], [\"Alt-Svc\", \"quic=\\\":443\\\"; ma=2592000; v=\\\"44,43,39,35\\\"\"]], @dumped=false>, @peer_cert=#<OpenSSL::X509::Certificate: subject=#<OpenSSL::X509::Name:0x007f81cb771290>, issuer=#<OpenSSL::X509::Name:0x007f81cb771268>, serial=#<OpenSSL::BN:0x007f81cb771240>, not_before=2018-08-14 07:48:19 UTC, not_after=2018-10-23 07:38:00 UTC>, @http_body=#<HTTP::Message::Body:0x007f81cb7906e0 @body=\"<!DOCTYPE html>\\n<html lang=en>\\n  <meta charset=utf-8>\\n  <meta name=viewport content=\\\"initial-scale=1, minimum-scale=1, width=device-width\\\">\\n  <title>Error 404 (Not Found)!!1</title>\\n  <style>\\n    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}\\n  </style>\\n  <a href=//www.google.com/><span id=logo aria-label=Google></span></a>\\n  <p><b>404.</b> <ins>That’s an error.</ins>\\n  <p>The requested URL <code>/v3/Ayenda%201011%20Chapinero/reviews?</code> was not found on this server.  <ins>That’s all we know.</ins>\\n\", @size=0, @positions=nil, @chunk_size=nil>, @previous=nil>\r\n    Caught error Invalid request\r\n    Error - #<Google::Apis::ClientError: Invalid request>\r\n\r\n    Google::Apis::ClientError: Invalid request\r\n    from /Users/andru1989/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/google-api-client-0.23.7/lib/google/apis/core/http_command.rb:218:in `check_status'\r\n\r\nI don't really know what to do, because as I can see there is not enough documentation about `Google::Apis::MybusinessV3`\r\n\r\nThanks in advance"},"comment":{"url":"https://api.github.com/repos/googleapis/google-api-ruby-client/issues/comments/431183153","html_url":"https://github.com/googleapis/google-api-ruby-client/issues/712#issuecomment-431183153","issue_url":"https://api.github.com/repos/googleapis/google-api-ruby-client/issues/712","id":431183153,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMTE4MzE1Mw==","user":{"login":"andru1989","id":406814,"node_id":"MDQ6VXNlcjQwNjgxNA==","avatar_url":"https://avatars0.githubusercontent.com/u/406814?v=4","gravatar_id":"","url":"https://api.github.com/users/andru1989","html_url":"https://github.com/andru1989","followers_url":"https://api.github.com/users/andru1989/followers","following_url":"https://api.github.com/users/andru1989/following{/other_user}","gists_url":"https://api.github.com/users/andru1989/gists{/gist_id}","starred_url":"https://api.github.com/users/andru1989/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andru1989/subscriptions","organizations_url":"https://api.github.com/users/andru1989/orgs","repos_url":"https://api.github.com/users/andru1989/repos","events_url":"https://api.github.com/users/andru1989/events{/privacy}","received_events_url":"https://api.github.com/users/andru1989/received_events","type":"User","site_admin":false},"created_at":"2018-10-18T22:18:19Z","updated_at":"2018-10-18T22:18:19Z","author_association":"NONE","body":"Hi @csga5000 \r\nSorry I Just see your answer a few minutes ago, I did what you suggest here https://github.com/googleapis/google-api-ruby-client/issues/662#issuecomment-428749661 but I still have problems with authentication, but I continue with the same issue:\r\n\r\nJust a question... Can I access to the list of `accounts` using just an API_KEY authentication ? I mean something like this:\r\n```\r\nMybusiness = Google::Apis::MybusinessV4\r\nservice = Mybusiness::MyBusinessService.new\r\nservice.key = 'MY_API_KEY'\r\nservice.list_accounts\r\n```\r\n\r\nI'm getting the following:\r\n```\r\nSending HTTP get https://mybusiness.googleapis.com/v4/accounts?key=.....\r\n401\r\n#<HTTP::Message:0x007fddb75f7458 @http_header=#<HTTP::Message::Headers:0x007fddb75f73b8 @http_version=\"1.1\", @body_size=0, @chunked=false, @request_method=\"GET\", @request_uri=#<Addressable::URI:0x3feedbad0e58 URI:https://mybusiness.googleapis.com/v4/accounts?key=AIzaSyB8TEBFRBVx9D4feaGLduSkKsJUAwtYB9E>, @request_query=nil, @request_absolute_uri=nil, @status_code=401, @reason_phrase=\"Unauthorized\", @body_type=nil, @body_charset=nil, @body_date=nil, @body_encoding=#<Encoding:UTF-8>, @is_request=false, @header_item=[[\"Vary\", \"Origin\"], [\"Vary\", \"X-Origin\"], [\"Vary\", \"Referer\"], [\"Content-Type\", \"application/json; charset=UTF-8\"], [\"Content-Encoding\", \"gzip\"], [\"Date\", \"Thu, 18 Oct 2018 21:52:36 GMT\"], [\"Server\", \"ESF\"], [\"Cache-Control\", \"private\"], [\"X-XSS-Protection\", \"1; mode=block\"], [\"X-Frame-Options\", \"SAMEORIGIN\"], [\"X-Content-Type-Options\", \"nosniff\"], [\"Alt-Svc\", \"quic=\\\":443\\\"; ma=2592000; v=\\\"44,43,39,35\\\"\"], [\"Transfer-Encoding\", \"chunked\"]], @dumped=false>, @peer_cert=#<OpenSSL::X509::Certificate: subject=#<OpenSSL::X509::Name:0x007fddb8af8d98>, issuer=#<OpenSSL::X509::Name:0x007fddb8af8d70>, serial=#<OpenSSL::BN:0x007fddb8af8d48>, not_before=2018-10-02 07:30:15 UTC, not_after=2018-12-25 07:30:00 UTC>, @http_body=#<HTTP::Message::Body:0x007fddb75f72a0 @body=\"{\\n  \\\"error\\\": {\\n    \\\"code\\\": 401,\\n    \\\"message\\\": \\\"Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.\\\",\\n    \\\"errors\\\": [\\n      {\\n        \\\"message\\\": \\\"Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.\\\",\\n        \\\"domain\\\": \\\"global\\\",\\n        \\\"reason\\\": \\\"unauthorized\\\"\\n      }\\n    ],\\n    \\\"status\\\": \\\"UNAUTHENTICATED\\\"\\n  }\\n}\\n\", @size=0, @positions=nil, @chunk_size=nil>, @previous=nil>\r\nCaught error Unauthorized\r\nError - #<Google::Apis::AuthorizationError: Unauthorized>\r\n\r\nRetrying after authentication failure\r\nGoogle::Apis::AuthorizationError: Unauthorized\r\nfrom /Users/andru1989/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/google-api-client-0.24.3/lib/google/apis/core/http_command.rb:212:in `check_status'\r\n```\r\n\r\nIf I can't access to `list_accounts` just with `API_KEY`, then I guess I need to use OAuth2, So I'm trying to do it as described here(https://github.com/googleapis/google-auth-library-ruby#example-command-line):\r\n\r\n```\r\nrequire 'googleauth'\r\nrequire 'googleauth/stores/redis_token_store'\r\n\r\ntoken_store = Google::Auth::Stores::RedisTokenStore.new(redis: Redis.new)\r\nclient_id = Google::Auth::ClientId.new(\"...\", \"...\")\r\nscope = \"https://www.googleapis.com/auth/plus.business.manage\"\r\nMybusiness = Google::Apis::MybusinessV4\r\nservice = Mybusiness::MyBusinessService.new\r\nauthorizer = Google::Auth::UserAuthorizer.new(client_id, scope, token_store)\r\n```\r\nfrom here I dont know how to get the `user_id` and then set it to the `service` instance\r\n\r\n```\r\ncredentials = authorizer.get_credentials(user_id)\r\nif credentials.nil?\r\n  url = authorizer.get_authorization_url(base_url: OOB_URI )\r\n  puts \"Open #{url} in your browser and enter the resulting code:\"\r\n  code = gets\r\n  credentials = authorizer.get_and_store_credentials_from_code(\r\n    user_id: user_id, code: code, base_url: OOB_URI)\r\nend\r\n```\r\n\r\nI really appreciate if you help me to solve this issue, I don't really know what to do in this case\r\n\r\nThanks in advance"}}
{"actor":{"display_login":"andru1989"}}