google-api-php-client

Can't Validate Google Access Token (wrong number of segments)

倖福魔咒の 提交于 2019-12-22 08:17:54
问题 I have very simple code directly from Google's website $client = new Google_Client(['client_id' => $CLIENT_ID]); $payload = $client->verifyIdToken($id_token); if ($payload) { $userid = $payload['sub']; echo $userid; } else { // Invalid ID token echo "error"; } I get the following error(s): <b>Fatal error</b>: Uncaught exception 'UnexpectedValueException' with message 'Wrong number of segments' in /../vendor/firebase/php-jwt/src/JWT.php:79 Stack trace: #0 /../vendor/google/apiclient/src/Google

Create a sub folder using google-drive-api and return the id with PHP

你。 提交于 2019-12-22 05:32:03
问题 I can create the sub folder just fine with the code below but I just can't return the id. I would like to get the id and/or the link to the folder so I can add them to my database. Currently the below creates the folder but just returns "//" as the id! Thanks for your help <?php if ($client->getAccessToken()) { $file = new Google_DriveFile(); //Setup the Folder to Create $file->setTitle('Project Folder'); $file->setDescription('A Project Folder'); $file->setMimeType('application/vnd.google

Google Calendar Push Notification watch command in php

倖福魔咒の 提交于 2019-12-22 05:31:56
问题 I am using the php watch commant: $service = new Google_Service_Calendar($client); $channel = new Google_Service_Calendar_Channel($client); $channel->setId('20fdedbf0-a845-11e3-1515e2-0800200c9a6689111'); $channel->setType('web_hook'); $channel->setAddress('https://www.exampel.com/app/notification'); $watchEvent = $service->events->watch('primary', $channel); This command works fine and I get the response: Google_Service_Calendar_Channel Object ( [address] => [expiration] => 1401960485000 [id

curl error 35 : Unknown SSL google OAuth2

早过忘川 提交于 2019-12-21 21:39:35
问题 I try to use Google php OAuth2 (google-api-php-client) and i have curl errno 35, but only when i use proxy : HTTP Error: (0) Unknown SSL protocol error in connection to accounts.google.com:8080 I test many solutions : // Test disabled verify peer & host CURLOPT_SSL_VERIFYPEER => false CURLOPT_SSL_VERIFYHOST => false ... // Test set proxy & auth proxy curl_setopt($ch, CURLOPT_PROXY, $proxy); curl_setopt($ch, CURLOPT_PROXYPORT, '8080'); curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyauth); ... //

Google API Fatal error: Uncaught LogicException: refresh token must be passed in or set as part of setAccessToken

前提是你 提交于 2019-12-20 06:48:15
问题 Working with the PHP Quickstart code, I found a problem: when the token needs to be refreshed, the code returns the following error: Fatal error: Uncaught LogicException: refresh token must be passed in or set as part of setAccessToken in /app/vendor/google/apiclient/src/Google/Client.php:258 Stack trace: #0 /app/gmail.php(32): Google_Client->fetchAccessTokenWithRefreshToken(NULL) #1 /app/test.php(14): getClient() #2 {main} thrown in /app/vendor/google/apiclient/src/Google/Client.php on line

Google API Insufficient Permissions listing files

左心房为你撑大大i 提交于 2019-12-20 03:23:24
问题 I am trying to create an app that (using a Drive service account) lists files in a given folder and allows users to search the content of those files. I am getting a 403 Insufficient Permissions error which I cannot explain. I have edited the code from the Google API PHP Client Example: $client_id = '[REMOVED]'; //Client ID $service_account_name = '[REMOVED]'; //Email Address $key_file_location = 'key.p12'; //key.p12 $client = new Google_Client(); $client->setApplicationName("Client_Library

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

大憨熊 提交于 2019-12-20 02:53:11
问题 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

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

女生的网名这么多〃 提交于 2019-12-20 02:42:24
问题 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(

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

回眸只為那壹抹淺笑 提交于 2019-12-20 02:42:14
问题 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(

Sending email notifications for Events via Google Calendar API

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-19 17:06:05
问题 I'm using the calendar.events.insert API to add an Event to my Calendar via the PHP client. The event is being inserted correctly along with appropriate values as set by the API. The same however is not able to trigger an email invite to the attendees. I looked around to find that the request needs to set the param sendNotifications as true . The same doesn't seem to help either. Here is a sample code: var request = gapi.client.calendar.events.insert({ "calendarId" : calendarData.id,