Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access Google calendar #9

Open
rashnk opened this issue Dec 26, 2015 · 8 comments
Open

Access Google calendar #9

rashnk opened this issue Dec 26, 2015 · 8 comments

Comments

@rashnk
Copy link

rashnk commented Dec 26, 2015

I tested with owncloud, its working.
is it possible to connect and access google calendar data ?

@daniu-de
Copy link

oh ... sorry - did not see this one ...

@damd22
Copy link

damd22 commented Feb 26, 2016

Hi,

i make a modification to connect google calendar to accept Oauth 2.0 .
If you'a interested, i can publied the code .

@rashnk
Copy link
Author

rashnk commented Feb 27, 2016

you are welcome, wht are the changes

@daniu-de
Copy link

Pls send a copy 2 me

Thanks

On 26 February 2016 22:56:17 CET, damd22 [email protected] wrote:

Hi,

i make a modification to connect google calendar to accept Oauth 2.0 .

If you'a interested, i can publied the code .


Reply to this email directly or view it on GitHub:
#9 (comment)

@daniu-de
Copy link

daniu-de commented Mar 5, 2016

Hi
I guess quite some ppl would appreciate the code. Can you post it somewhere please?
Regards

On 26 February 2016 22:56:17 CET, damd22 [email protected] wrote:

Hi,

i make a modification to connect google calendar to accept Oauth 2.0 .

If you'a interested, i can publied the code .


Reply to this email directly or view it on GitHub:
#9 (comment)

@damd22
Copy link

damd22 commented Mar 6, 2016

Hi,
i'm sorry, i didn't have much time to do it.

Prerequisite It is necessary to recover the oauth token , i don't explain it here .

I modified in CalDAVClient class to add tokenOauth attribut, and add $tokenOauth parameter in the construct function .

`  class CalDAVClient {
  /**
  * Server, username, password, calendar, tokenOauth
  *
  * @var string
  */
  protected $base_url, $user, $pass, $entry, $protocol, $server, $port,$tokenOauth;
....
  function __construct( $base_url, $user, $pass,$tokenOauth, $options = array()) {
      $this->user = $user;
      $this->pass = $pass;
     ** $this->tokenOauth = $tokenOauth;**
      $this->headers = array();

      if ( preg_match( '#^((https?)://([a-z0-9.-]+)(:([0-9]+))?)(/.*)$#', $base_url, $matches ) ) {

I modified also in CalDAVClient class the DoRequest function to add option in header HTML request if tokenOauth is not null :

`function DoRequest( $url = null ) {
      if (is_null($url)) {
          $url = $this->full_url;
      }
      $this->request_url = $url;
      curl_setopt($this->ch, CURLOPT_URL, $url);
      // Request method
      curl_setopt($this->ch, CURLOPT_CUSTOMREQUEST, $this->requestMethod);

      // Empty body. If not used, cURL will spend ~5s on this request
      if ($this->requestMethod == 'HEAD' || empty($this->body) ) {
          curl_setopt($this->ch, CURLOPT_NOBODY, TRUE);
      } else {
          curl_setopt($this->ch, CURLOPT_NOBODY, FALSE);
      }

      // Headers
      if (!isset($this->headers['content-type'])) $this->headers['content-type'] = "Content-type: text/plain";

      // Remove cURL generated 'Expect: 100-continue'
      $this->headers['disable_expect'] = 'Expect:';

**      //   Oauth identification
      if ($this->tokenOauth!=null){
          $this->headers['authorization']="Authorization: Bearer " . $this->tokenOauth;
      }**

      curl_setopt($this->ch, CURLOPT_HTTPHEADER,
              array_values($this->headers));
    ...
`

After in SimpleCalDAVClient class the connect function i add optionnal $tokenOauth parameter.

function connect ( $url, $user, $pass, $tokenOauth=null ) { // Connect to CalDAV-Server and log in $client = new CalDAVClient2($url, $user, $pass,$tokenOauth);

finally, if i want to connect google calendar, i do :
$this->clientCalDAV->connect($serveur, '' , '',$token);

and if i want to connect classical caldav serveur , i do
$this->clientCalDAV->connect($serveur, $login, $mdp,'');

it would be nice to integrate this development in the package :)

Damien

@daniu-de
Copy link

daniu-de commented May 2, 2016

Hi,
Thanks a lot for you code!
I tried to follow your example, but some things are not really clear to me yet:
*which URL do you use to access the google server?
*which ID do you use for the calendar? Where do you find it?
*honestly: the process of getting the oauth token is also not 100% clear to me - do I need to add the name of my php script somewhere on google? Or do I just create a new project on google, add the right apis and copy the token to my script? Which one is the token then? There is a json-file which can be downloaded - which one is the token? filename or inside the file?
Would be great to get these infos ...
regards

@daniu-de
Copy link

Hi,
do you or someone else think you can give me some more advice how to get this running?

would be cool
regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants