Open rashnk opened 8 years ago
oh ... sorry - did not see this one ...
Hi,
i make a modification to connect google calendar to accept Oauth 2.0 . If you'a interested, i can publied the code .
you are welcome, wht are the changes
Pls send a copy 2 me
Thanks
On 26 February 2016 22:56:17 CET, damd22 notifications@github.com 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: https://github.com/wvrzel/simpleCalDAV/issues/9#issuecomment-189498979
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 notifications@github.com 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: https://github.com/wvrzel/simpleCalDAV/issues/9#issuecomment-189498979
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
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
Hi, do you or someone else think you can give me some more advice how to get this running?
would be cool regards
I tested with owncloud, its working. is it possible to connect and access google calendar data ?