google-api-php-client

Google-api-php Refresh Token returns invalid_grant

冷暖自知 提交于 2019-11-30 09:16:11
I've nearly searched every result of the first page of google for this. But can't seem to find the answer. I'm working with a refresh_token by Google's API and receiving: Error refreshing the OAuth2 token, message: '{ "error" : "invalid_grant" } What i'm doing. First: i'm creating and storing a persistant connection to the google api: $client = new Google_Client(); $client->setClientId('xxxxxx-s73q0pa41aq3i2kcpatmpas6e6kkp99h.apps.googleusercontent.com'); $client->setClientSecret('xxxxxxxxxxxx'); $client->setRedirectUri('http://xxxxxxxx/generaterefreshtoken.php'); $client->setScopes(array(

In Google API v2, why is the error “The project id used to call the Google Play Developer API has not been linked” happening?

孤人 提交于 2019-11-30 04:11:32
问题 When I'm using Google API v2, to get an inapp listing, I'm getting the following error when I'm making the API call: { "error": { "errors": [ { "domain": "androidpublisher", "reason": "projectNotLinked", "message": "The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console." } ], "code": 403, "message": "The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console." } } I then

Google API Service Account Authorization Error

十年热恋 提交于 2019-11-30 02:28:31
I am using the google-api-php-client client to connect to Google Drive using a Service Account. Most of the time it works, but every so often (say if I sit here an refresh the page over and over it's every 5th to 10th time), I receive a Google_Service_Exception with the message unauthorized_client: Client is unauthorized to retrieve access tokens using this method . The error only occurs if the $this->drive_service->files->listFiles() code is present. It does not occur if I use the Service Account directly rather than using setSubject() to impersonate another user. $this->client = new Google

How to create a public Google Doc through the Drive API (PHP client)

心不动则不痛 提交于 2019-11-29 15:41:43
问题 This is what I've got so far, by combining this and this: require_once "google-api-php-client/src/Google_Client.php"; require_once "google-api-php-client/src/contrib/Google_DriveService.php"; require_once "google-api-php-client/src/contrib/Google_Oauth2Service.php"; //First, build a Drive service object authorized with the service accounts $auth = new Google_AssertionCredentials( DRIVE_SERVICE_ACCOUNT_EMAIL, array( DRIVE_SCOPE ), file_get_contents( DRIVE_SERVICE_ACCOUNT_KEY ) ); $client = new

Google-api-php Refresh Token returns invalid_grant

空扰寡人 提交于 2019-11-29 14:16:14
问题 I've nearly searched every result of the first page of google for this. But can't seem to find the answer. I'm working with a refresh_token by Google's API and receiving: Error refreshing the OAuth2 token, message: '{ "error" : "invalid_grant" } What i'm doing. First: i'm creating and storing a persistant connection to the google api: $client = new Google_Client(); $client->setClientId('xxxxxx-s73q0pa41aq3i2kcpatmpas6e6kkp99h.apps.googleusercontent.com'); $client->setClientSecret(

Getting “Unable to parse the p12 file…” Error With google-api-php-client

我怕爱的太早我们不能终老 提交于 2019-11-29 13:27:12
I've been searching for days and trying new and older version of google-api-php-client along with various other examples out there, but I can't seem to get around this error. The code below is the service-account example retrieved from GitHub and I dropped in my credentials and file from the API Console. I've got a different file I'm actually building, but for use in this question, I figure this simpler file would be easier to discuss. I'm getting the same error with both files. Fatal error: Uncaught exception 'Google_Auth_Exception' with message 'Unable to parse the p12 file. Is this a .p12

Google php client library loadServiceAccountJson broken - fix enclosed

我的未来我决定 提交于 2019-11-29 13:01:15
The new function in the php library loadServiceAccountJson doesn't allow setting sub in the Google_Auth_AssertionCredentials creator, so always gives authorization fails. How do we get the library updated? The following instructions will allow a working query, in my case to the Admin SDK Directory API: First, update the php library function loadServiceAccountJson in src/Google/Client.php to this: public function loadServiceAccountJson($jsonLocation, $scopes) { $data = json_decode(file_get_contents($jsonLocation)); if (isset($data->type) && $data->type == 'service_account') { // Service Account

Youtube Analytics API PHP Invalid query. Query did not conform to the expectations

拟墨画扇 提交于 2019-11-29 12:35:51
I'm trying to make some analytics query from server to server. I'm using laravel with https://github.com/google/google-api-php-client library. This is the code I'm using: $client = new Google_Client(); $key = file_get_contents(storage_path('key.p12')); $cred = new Google_Auth_AssertionCredentials( '***@developer.gserviceaccount.com', array('https://www.googleapis.com/auth/youtube.readonly', 'https://www.googleapis.com/auth/yt-analytics.readonly'), $key); $client->setAssertionCredentials($cred); if ($client->getAuth()->isAccessTokenExpired()) { $client->getAuth()->refreshTokenWithAssertion(

google analytics custom plugin getting error invalid grant

心已入冬 提交于 2019-11-29 12:13:35
$client = new Google_Client(); $client->setAuthConfigFile(plugin_dir_url( __FILE__ ) . '/client_secrets.json'); $client->setRedirectUri('urn:ietf:wg:oauth:2.0:oob'); $client->addScope(Google_Service_Analytics::ANALYTICS_READONLY); $client->setIncludeGrantedScopes(true); $client->setAccessType('offline'); $client->revokeToken(); $auth_url = $client->createAuthUrl(); using a popup authentication with javascript and then if (!isset($_SESSION['access_token'])) { //$client->authenticate($_GET['code']); if($client->isAccessTokenExpired()){ $client->authenticate($this->options['authenication_code']);

Trying to append a row to a Google Spreadsheet in PHP

徘徊边缘 提交于 2019-11-29 10:56:43
I'm using Google's Client API via Composer ( https://packagist.org/packages/google/apiclient ) and I have successfully authenticated and received an access token. I am trying to add a row to a Google sheet in my drive, but I can't find any relevant documentation that specifically addresses PHP. Here's what I've got so far: $service = new Google_Service_Sheets($a4e->google); // my authenticated Google client object $spreadsheetId = "11I1xNv8cHzBGE7uuZtB9fQzbgrz4z7lIaEADfta60nc"; $range = "Sheet1!A1:E"; $valueRange= new Google_Service_Sheets_ValueRange(); $service->spreadsheets_values->update(