google-api-php-client

access user calendar with service account

只谈情不闲聊 提交于 2019-12-02 02:34:23
I have a php application on my intranet that needs to add events in the calenders of my users. I followed the following instructing https://developers.google.com/+/domains/authentication/delegation I setup the google-api-php client and used the example service-accounts.php as my starting point. $client_id = 'rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr.apps.googleusercontent.com'; $service_account_name = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy@developer.gserviceaccount.com'; $key_file_location = 'file.p12'; $client = new Google_Client(); $client->setApplicationName("egw - intranet"); $service = new

Fatal error: Uncaught exception 'Google_Auth_Exception' with message 'Error refreshing the OAuth2 token, message: '{ “error” : “invalid_grant” }

这一生的挚爱 提交于 2019-12-02 01:57:00
问题 I have a Prediction app that's based on Google-api-php client version 1.0.0 latest. it's perfectly working in the localhost environment. but when I deploy same exact app into the hosting server environment it's gave me following issue. THIS IS THE ERROR I GOT FROM HOSTING ENVIRONMENT Fatal error: Uncaught exception 'Google_Auth_Exception' with message 'Error refreshing the OAuth2 token, message: '{ "error" : "invalid_grant" }'' in /home/predict/public_html/predict/Google/Auth/OAuth2.php:335

require_once(Google/Auth/AssertionCredentials.php): failed to open stream: No such file or directory

纵饮孤独 提交于 2019-12-02 01:36:24
问题 I'm trying to do a very simple: require_once 'vendor/google/src/Google/Client.php'; require_once 'vendor/google/src/Google/Service/Plus.php'; ...and I get this error: require_once(Google/Auth/AssertionCredentials.php): failed to open stream: No such file or directory Why? I'm using the latest version available on https://github.com/google/google-api-php-client and seems that in Client.php each require_once uses a wrong path... or not? Any help will be greatly appreciated! Thanks a lot,

Google Client Invalid JWT: Token must be a short-lived token

一曲冷凌霜 提交于 2019-12-02 01:33:01
I am using Google's php api client . I am running through the quickstart guide for service accounts. I followed the steps perfectly (as far as I can tell). I am running into the following error: { "error": "invalid_grant", "error_description": "Invalid JWT: Token must be a short-lived token (60 minutes) and in a reasonable timeframe. Check your iat and exp values and use a clock with skew to account for clock differences between systems." } From what I have read the most common problem with this error is if the system time is wrong. I have triple checked that my timezone and date and time are

Google API: “invalid_grant”, but the code haven't changed

Deadly 提交于 2019-12-02 01:01:37
I have the following problem with authentication to Google API: PHP Fatal error: Uncaught exception 'Google_Auth_Exception' with message 'Error refreshing the OAuth2 token, message: '{ "error" : "invalid_grant" }'' in /home/bot/bot/vendor/google/apiclient/src/Google/Auth/OAuth2.php:328 However, the issue is very strange, because same code works on my local PC and stops working on the server. Is it possible, that it has something to do with server time? I have my system clock synchronized, but server is about ~1 minute backwards. Seriously, I ran out of ideas why it doesn't work anymore though

Google OAuth: can't get refresh token with authorization code

笑着哭i 提交于 2019-12-02 00:37:36
I am using Google API Client for Google Analytics with OAuth 2.0 I read this to get the refresh token but it doesn't appears: https://developers.google.com/identity/protocols/OAuth2WebServer#offline I only get this instead: { "access_token": "ya29.twHFi4LsiF-AITwzCpupMmie-fljyTIzD9lG8y_OYUdEGKSDL7vD8LPKIqdzRwvoQAWd", "token_type": "Bearer", "expires_in": 3599, "id_token": "very long string" } Here is the code: Javascript (to get the Authorization Code): that works gapi.analytics.ready(function() { gapi.analytics.auth.authorize({ container: 'embed-api-auth-container', clientid: '257497260674

How to troubleshoot/get error response when you run invalid BigQuery jobs?

别等时光非礼了梦想. 提交于 2019-12-01 20:32:01
In this code, I try to run a select on a table that doesn't exists, getJobReference() returns NULL and I would love to catch this kind of error, and would like to error messages obtained somehow. How to obtain the error message when something fails? $client = new Google_Client(); $client->setApplicationName("Client_Library_Examples"); //$client->setDeveloperKey(API_KEY); if (isset($_SESSION['service_token'])) { $client->setAccessToken($_SESSION['service_token']); } $key = file_get_contents($key_file_location); $cred = new Google_Auth_AssertionCredentials( $service_account_name, array( 'https:/

Fatal error: Uncaught exception 'Google_Auth_Exception' with message 'Error refreshing the OAuth2 token, message: '{ “error” : “invalid_grant” }

北战南征 提交于 2019-12-01 20:16:38
I have a Prediction app that's based on Google-api-php client version 1.0.0 latest. it's perfectly working in the localhost environment. but when I deploy same exact app into the hosting server environment it's gave me following issue. THIS IS THE ERROR I GOT FROM HOSTING ENVIRONMENT Fatal error: Uncaught exception 'Google_Auth_Exception' with message 'Error refreshing the OAuth2 token, message: '{ "error" : "invalid_grant" }'' in /home/predict/public_html/predict/Google/Auth/OAuth2.php:335 Stack trace: #0 /home/predict/public_html/predict/Google/Auth/OAuth2.php(294): Google_Auth_OAuth2-

How can I create a folder within a Team Drive with the Google API?

不羁的心 提交于 2019-12-01 19:59:07
问题 I'm struggling to create a folder within a Team Drive using the Google API PHP Client Library. I am using a service account and impersonating a user (myself) who is a member of the Team Drive and can list the contents of the drive. However, when I create a folder it always creates it in 'My Drive' rather than the Team Drive specified. Attempt 1 $client = new Google_Client(); $client->useApplicationDefaultCredentials(); $client->addScope("https://www.googleapis.com/auth/drive"); $client-

Exclude live events from YouTube data api search query

拜拜、爱过 提交于 2019-12-01 18:54:25
I'm using the google-api-php-client ( https://github.com/google/google-api-php-client ) to search and retrieve only videos from YouTube. I know you can set a query marker called type to video like this: $searchquery = array( 'q' => "flux", 'maxResults' => 10, 'type' => 'video', 'videoDuration' => 'short', 'videoEmbeddable' => 'true' ); However it seems to also return live events/livestreams in the search results. Is there a way to exclude live event videos? They have a marker called [liveBroadcastContent] => upcoming so I can do post-search but that's not ideal. Thanks in advance. edit: on