I'm trying to use AuthSub to get access to Google Calendar feeds from a 
hosted domain.

I need to use Perl to accomplish this. I have registered my 
domain/application with Google and am getting intial AuthSub tokens fine. I 
am able to exchange those initial tokens for session tokens fine as well. 
But when I try to get Calendar feeds, it says the token is invalid. When I 
test this session token with AuthSubTokenInfo, it also tells me the token is 
invalid.

I am not trying to use secure tokens yet. 

Can someone point out if I'm doing something obviously wrong?

Here's my initial link to get AuthSub token:

my $googleNextUrl = uri_escape('https://www.my-website.edu/');

my $googleScopeUrl = uri_escape('https://www.google.com/calendar/feeds');

my $googleAuthSubUrl = 
'https://www.google.com/accounts/AuthSubRequest?next=' . $googleNextUrl . 
'&scope=' . $googleScopeUrl . '&session=1&hd=mydomain.edu';


Then I exchange that token for a AuthSub session token:

    my $url = 'https://www.google.com/accounts/AuthSubSessionToken';

    my $ua = LWP::UserAgent->new();
    $ua->agent('My Website');

    my $req = HTTP::Request->new(
        'GET',
        "$url",
        [
            'Authorization' => 'AuthSub token="' . $token . '"',
        ],
    );

    my $response = $ua->request($req);

    if ($response && $response->is_success)  {
        return $response;
    }


Then I parse the response from AuthSubSessionToken:

my $sessionToken = substr($response, index($response, '=') + 1);



Then I try sending the session token to either AuthSubTokenInfo, or 
https://www.google.com/calendar/feeds/default/private/full

    my $url = 'https://www.google.com/calendar/feeds/default/private/full';

    my $ua = LWP::UserAgent->new();
    $ua->agent('My Website');

    my $req = HTTP::Request->new(
        'GET',
        "$url",
        [
            'Authorization' => 'AuthSub token="' . $token . '"',
        ],
    );

    my $response = $ua->request($req);

    if ($response && $response->is_success)  {
        return $response->content;
    }


So if I output when I'm getting it looks like this:

AuthSub Token: 1/jtxZsBCbbNAgR_dIbakVoyUcpM6TdS_f0nmxiptBUU4

Google AuthSubSession Response: 200 OK : 
Token=1/uWAXg--XraXBjK3uNnWwoZVCUviXTLxoiORCV67-bBQ 

Session Token: 1/uWAXg--XraXBjK3uNnWwoZVCUviXTLxoiORCV67-bBQ 

AuthSubTokenInfo Response: 403 Invalid AuthSub token.


I'm not sure if there's a way to get more info from Google's error response, 
or if I need to be using secure tokens to use a hosted domain. The docs 
indicate you don't have to use secure tokens necessarily.

-- 
You received this message because you are subscribed to the Google
Groups "Google Calendar Data API" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://code.google.com/apis/calendar/community/forum.html

Reply via email to