asimlqt / php-google-spreadsheet-client

A PHP library for accessing and manipulating Google Spreadsheets
Other
543 stars 154 forks source link

Why is Google_Http_Request not used? #109

Closed wstoettinger closed 8 years ago

wstoettinger commented 8 years ago

Hey there!

i spent a lot of time trying to make your library work on google app engine. unfortunately i keep running into new problems trying to do so.

irrespective of the app engine problem i'm wondering why you haven't used the Google_Http_Request class which is available in the Google API? It seems plausible to me, that this class is intended to handle requests.

Coming back to my problem: Google_Auth_AppIdentity, which is necessary for server to server authentication on App Engine relies on the Google_Http_Request.

have you had a look into this class?

asimlqt commented 8 years ago

Hey, thanks for the comment.

This library was initially intended to run standalone. Google App Engine was not the target or any other third party service for that matter.

Also it was created without any other dependencies. However it does require an access token to work but it's up to the developer how they generate the token. If they choose to use the official Google PHP library or not that's up to the developer.

Although I might consider using it in the future.

wstoettinger commented 8 years ago

you did, however, explicitly reference that the Google API is necessary to generate an access token, which makes this library a dependency even though it's not used by your code. would you be interested to work on a new version together which builds on the google API (and therefore is also compatible with google app engine?). Google still references the ZEND Framework Version 1 in their Google Data API Docs which doesn't seem to work with server2server oauth authentication using a service account and is a pain in the ass to use. so i'm definitely seeing some demand to get a proper library up and running here!

asimlqt commented 8 years ago

I am currently stacked with work so rewriting in the near future is not possible. It maybe something to consider in the next version, whenever Google decide to update it.

Yes I do provide an example of generating an access token using the Google PHP Client, however it is not "necessary", but it is the quickest way to generate one in PHP in my opinion.

Unfortunately, I don't use GAE so I haven't tested it on there. This library uses curl and GAE does support it in some form, so I'm not sure why it wouldn't work. What error do you get?

The main reason for not going out of my to support GAE is because they manage there own custom version of PHP. This library works with the standard PHP platform that all other vendors use so if it doesn't work because one company decided to modify it to suit their needs then tough.

wstoettinger commented 8 years ago

I understand your point!

As far as I remember, the reason why it didn't work is, that one can't create an Access Token on GAE for service accounts ... i think it's not even necessary (or possible) to have a service account.

so curl would work, but since there's no access token (or at least the Auth object which generates it, doesn't give it away (see Google_Auth_AppIdentity)), the request needs to be authenticated in another way.

This somehow works with the authenticateForScope method, for more details see: https://developers.google.com/api-client-library/php/auth/service-accounts

asimlqt commented 8 years ago

Hey,

I just signed up for the free trial account on App Engine and was able to use use this library within minutes. So there is no issue with this library running on App Engine.

Once you have a valid access token by whichever method you choose then this library should work fine. You need read up on how Google service account authentication works, I have tested that separately previously (not on App Engine) and it works fine.

NB. I did have to enable curl lite in php.ini to get it to work on App Engine.