{"action":"created","issue":{"url":"https://api.github.com/repos/google/google-api-php-client/issues/1144","repository_url":"https://api.github.com/repos/google/google-api-php-client","labels_url":"https://api.github.com/repos/google/google-api-php-client/issues/1144/labels{/name}","comments_url":"https://api.github.com/repos/google/google-api-php-client/issues/1144/comments","events_url":"https://api.github.com/repos/google/google-api-php-client/issues/1144/events","html_url":"https://github.com/google/google-api-php-client/issues/1144","id":205240298,"number":1144,"title":"Search Console API returns Empty array for site list even though I have several sites in my search console","user":{"login":"himmerman","id":2037124,"avatar_url":"https://avatars.githubusercontent.com/u/2037124?v=3","gravatar_id":"","url":"https://api.github.com/users/himmerman","html_url":"https://github.com/himmerman","followers_url":"https://api.github.com/users/himmerman/followers","following_url":"https://api.github.com/users/himmerman/following{/other_user}","gists_url":"https://api.github.com/users/himmerman/gists{/gist_id}","starred_url":"https://api.github.com/users/himmerman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/himmerman/subscriptions","organizations_url":"https://api.github.com/users/himmerman/orgs","repos_url":"https://api.github.com/users/himmerman/repos","events_url":"https://api.github.com/users/himmerman/events{/privacy}","received_events_url":"https://api.github.com/users/himmerman/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-02-03T18:56:58Z","updated_at":"2017-02-09T23:11:38Z","closed_at":"2017-02-09T23:11:31Z","body":"I've downloaded the library and authenticated using service accounts. What I am attempting to do is to get the impressions, clicks, and position of each site in my search console on a linux process and put that data into a database for further reporting.\r\n\r\nHowever, every time I try to just get the list of sites in the search console, it results in an empty array. This is my code.\r\n\r\n```\r\n$creds = realpath('./lib/Google/search-console-tester-4408001ccc73.json');\r\nputenv('GOOGLE_APPLICATION_CREDENTIALS='.$creds);\r\n$this->client = new Google_Client();\r\n$this->client->useApplicationDefaultCredentials();\r\n$this->client->setSubject('tester@search-console-tester.iam.gserviceaccount.com');\r\n$this->client->addScope('https://www.googleapis.com/auth/webmasters');\r\n$this->client->addScope('https://www.googleapis.com/auth/webmasters.readonly');\r\n\r\n$this->search_console = new Google_Service_Webmasters($this->client);\r\n$site_list = $this->search_console->sites->listSites()->siteEntry;\r\nvar_dump($site_list);\r\n```\r\n$site_list is empty. This api gives me a list of websites in the API explorer and on the API dashboard it says it was a successful query so I know its hitting the API. But what is going on with this. Should be a pretty simple return of data.\r\n"},"comment":{"url":"https://api.github.com/repos/google/google-api-php-client/issues/comments/278805422","html_url":"https://github.com/google/google-api-php-client/issues/1144#issuecomment-278805422","issue_url":"https://api.github.com/repos/google/google-api-php-client/issues/1144","id":278805422,"user":{"login":"himmerman","id":2037124,"avatar_url":"https://avatars.githubusercontent.com/u/2037124?v=3","gravatar_id":"","url":"https://api.github.com/users/himmerman","html_url":"https://github.com/himmerman","followers_url":"https://api.github.com/users/himmerman/followers","following_url":"https://api.github.com/users/himmerman/following{/other_user}","gists_url":"https://api.github.com/users/himmerman/gists{/gist_id}","starred_url":"https://api.github.com/users/himmerman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/himmerman/subscriptions","organizations_url":"https://api.github.com/users/himmerman/orgs","repos_url":"https://api.github.com/users/himmerman/repos","events_url":"https://api.github.com/users/himmerman/events{/privacy}","received_events_url":"https://api.github.com/users/himmerman/received_events","type":"User","site_admin":false},"created_at":"2017-02-09T23:11:38Z","updated_at":"2017-02-09T23:11:38Z","body":"up vote\r\n0\r\ndown vote\r\naccept\r\nSearch console sites and site data is considered user data and cannot be accessed by service accounts. You have to make an Oauth 2 interface and save the token to a file and use that token in your app. Make sure the app refreshes the token when it expires:\r\n\r\nif ($client->isAccessTokenExpired()) {\r\n        $client->refreshToken($this->token['refresh_token']);\r\n        $token = $client->getAccessToken(); // save this to a file\r\n    }\r\n"}}
{"actor":{"display_login":"himmerman"}}