google-api-php-client

Google API Client “refresh token must be passed in or set as part of setAccessToken”

╄→尐↘猪︶ㄣ 提交于 2019-11-27 04:26:20
问题 I am currently facing a very strange problem, indeed I've been following this very same guide (https://developers.google.com/google-apps/calendar/quickstart/php) from Google API documentation. I tried it twice, at the first time it work like a charm but after the access token had expire the script provided straight by Google API Doc was unable to refresh it. TL;DR Here is the error message: sam@ssh:~$ php www/path/to/app/public/quickstart.php Fatal error: Uncaught exception 'LogicException'

Google Calendar API v3 - authenticate with hardcoded credentials

落花浮王杯 提交于 2019-11-27 03:41:45
I am writing a PHP application that's supposed to allow users to add certain events to a private Google Calendar. The calendar is owned by me, and I need a way for PHP to communicate with the calendar API using fixed credentials (everyone can add events using a form on the website, but the calendar itself is not publicly visible). From what I have read, this is possible using ClientLogin in the v1 API. In the v3 API, however, the available options are OAuth2.0 or the API key. Using the API key doesn't seem to work, since it can only be used for requests that don't require authorization, and

Google Calendar API v3 - Not Creating Event (Server-to-Server Authentication)

梦想的初衷 提交于 2019-11-27 03:39:41
问题 So after digging around for several hours, I'm at a loss for a solution. I'm attempting to create an event on my primary calendar using v3 of Google's Calendar API, but I'm not experiencing the expected behavior. I'm using server-to-server authentication in this instance. To do that I created service account credentials, moved my key pair to the same directory as my test script, and set Google Calendar API to "On" within the developer console. Below you'll find the code at issue. The expected

How do I access the Google Spreadsheets API in PHP?

微笑、不失礼 提交于 2019-11-27 03:10:06
问题 Starting with the Google Developer documentation on the Google Spreadsheets API, I found that "A number of client libraries are provided in various languages.", but Google only provides client libraries for Java and .NET. For a PHP library, they recommend using Zend GData. So, I headed over the the Zend GData repo, and Zend says that their GData component is discontinued, and to use Google APIs Client Library for PHP. That library doesn't work with the Spreadsheets API, for that you have to

Get Userinfo from Google OAuth 2.0 PHP API

大兔子大兔子 提交于 2019-11-27 02:10:55
问题 I am trying to use Google Oauth API to get userinfo. It works perfectly for Google Plus API but I am trying to create a backup in case the user doesn't have google plus account. The authentication process is correct and I even get the $userinfo object but how exactly do I access the properties. I tried $userinfo->get() but it only return the id of the user. Am I doing something wrong? Here is the code that I am using... require_once '../../src/Google_Client.php'; require_once '../../src

Inserting Google Calendar Entries with Service Account

依然范特西╮ 提交于 2019-11-27 01:47:50
I'm trying to use a service account to create entries on a Google calendar. I'm really close on this, but the very last line won't work. I get a 500 Internal Service Error when I let this run. Otherwise, the program runs error free, for whatever that is worth. The Calendar.php file contents can be found here . The insert() method that I am trying to call begins on line 1455 of that file. <?php function calendarize ($title, $desc, $ev_date, $cal_id) { session_start(); /************************************************ Make an API request authenticated with a service account. ********************

Upload video to Youtube using Youtube API V3 and PHP

旧巷老猫 提交于 2019-11-27 00:02:21
问题 I am trying to upload a video to Youtube using PHP. I am using Youtube API v3 and I am using the latest checked out source code of Google API PHP Client library. I am using the sample code given on https://code.google.com/p/google-api-php-client/ to perform the authentication. The authentication goes through fine but when I try to upload a video I get Google_ServiceException with error code 500 and message as null. I had a look at the following question asked earlier: Upload video to youtube

Google Drive PHP API - Simple File Upload

会有一股神秘感。 提交于 2019-11-26 22:01:10
I am trying to write a small script to upload a local file to Google Drive, using Google Drive PHP API. The documentation is very poor maintained, but so far I am pretty sure the code should be looking like that: <?php include_once 'Google/Client.php'; include_once 'Google/Service/Drive.php'; include_once 'Google/Auth/OAuth2.php'; $client = new Google_Client(); $client->setScopes(array('https://www.googleapis.com/auth/drive.file')); $client->setClientId('dfgdfgdg'); $client->setClientSecret('dfgdfgdf'); $client->setRedirectUri('urn:ietf:wg:oauth:2.0:oob'); $service = new Google_Service_Drive(

How to list Google Calendar Events without User Authentication

旧时模样 提交于 2019-11-26 21:44:20
问题 On November 17, 2014 Google deprecated v1 and v2 of its Google Calendar API using the Zend Framework. It seems the only way to list publicly shared events on a publicly shared Google Calendar is through the new Google Client Library API from GitHub using OAuth 2.0 This means visitors to a public website that used to display public events now have to authenticate and login. Is that true? Is there no other way to continue to show public Google Calendar events? 回答1: What you need to do is use a

Token must be a short-lived token and in a reasonable timeframe

亡梦爱人 提交于 2019-11-26 20:28:36
I am having the same error as this . In my case it is happening when the app is trying to upload a file via Google Cloud Client API. POST https://www.googleapis.com/oauth2/v4/token 400 Bad Request Invalid JWT: Token must be a short-lived token and in a reasonable timeframe How I load the token is reading a service-account json file, and attach it to CURLOPT_HTTPHEADER in PHP. It did work properly for the past one month, so I am guessing that Google changed the way of authorization. Has anyone faced & solved this? WNG I stumbled upon the same issue at roughly the same time, so I expected a