Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. Import Google contacts using Authsub(Secure connection)

Import Google contacts using Authsub(Secure connection)

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
cryptographyhelpdatabasecomdata-structures
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Paresh1462
    wrote on last edited by
    #1

    Hello friends, I am learning google API I want to retrieve google contacts using Authsub. And second thing is that i want to use secure token. I have X.509 certificate with private key. In first step I got token but in second step (To get AuthSubSessionToken) I got error : Invalid AuthSub token. Here my code. please, anybody have idea ? Help me....

    $url = "https://www.google.com/accounts/AuthSubSessionToken";
    $token = $token;
    $param['sigalg'] = "rsa-sha1";
    $nonce = "15948".time()."49418"; // any random no(20 digit)
    $param['data'] = "GET https://www.google.com/accounts/AuthSubSessionToken ".time()." ".$nonce;
    $private_key = "MY_PRIVATE_KEY";

    $kvpairs = array();
    foreach ($param as $k => $v) {
    array_push($kvpairs, ($k . '=' . $v));
    }
    $query_string = '';
    $query_string = implode('&', $kvpairs);
    $base_string = 'GET'.'&'.$url .'&'.$query_string;
    $param['sig'] = base64_encode(hash_hmac('sha1', $base_string, $private_key, true));
    uksort($param, 'strcmp');
    $header = 'Authorization: AuthSub token="'.$token.'" ';
    foreach ($param as $k => $v)
    {
    $header .= $k . '="' .$v. '" ';
    }

        $header = trim($header," ");
    $headers\[\]= $header;
    $ch = curl\_init();
    curl\_setopt($ch, CURLOPT\_URL,$url);
    curl\_setopt($ch, CURLOPT\_RETURNTRANSFER, true);
    curl\_setopt($ch, CURLOPT\_SSL\_VERIFYPEER, false);
    curl\_setopt($ch, CURLOPT\_HTTPHEADER, $headers);
    $responce = curl\_exec($ch);
    curl\_close($ch);
    
    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups