Committer: ailyin
LJSUP-8688 (Google integration)U trunk/bin/upgrading/en_LJ.dat U trunk/cgi-bin/LJ/Client/Google.pm U trunk/cgi-bin/LJ/Identity/Google.pm U trunk/htdocs/identity/callback-google.bml
Modified: trunk/bin/upgrading/en_LJ.dat =================================================================== --- trunk/bin/upgrading/en_LJ.dat 2011-05-03 06:56:52 UTC (rev 10465) +++ trunk/bin/upgrading/en_LJ.dat 2011-05-03 07:06:33 UTC (rev 10466) @@ -1709,6 +1709,16 @@ [[siteroot]]/ . +email.newacct.google.body<< +Hi [[display_name]], + +You've connected your Google account with LiveJournal; to complete the process, +click the following link to verify your email address: [[conflink]]. + +[[sitename]] Team +[[siteroot]]/ +. + email.newacct.subject=Welcome to LiveJournal email.newacct.twitter.body<< Modified: trunk/cgi-bin/LJ/Client/Google.pm =================================================================== --- trunk/cgi-bin/LJ/Client/Google.pm 2011-05-03 06:56:52 UTC (rev 10465) +++ trunk/cgi-bin/LJ/Client/Google.pm 2011-05-03 07:06:33 UTC (rev 10466) @@ -13,6 +13,8 @@ if ( my $code = $opts->{'code'} ) { $postdata->{'code'} = $code; $postdata->{'grant_type'} = 'authorization_code'; + $postdata->{'redirect_uri'} + = "$LJ::SITEROOT/identity/callback-google.bml"; } elsif ( my $refresh_token = $opts->{'refresh_token'} ) { $postdata->{'refresh_token'} = $refresh_token; @@ -77,12 +79,11 @@ } my $url = 'https://www-opensocial.googleusercontent.com/' - . 'api/people/@me/@self?' - . 'oauth_token=' . $access_token; + . 'api/people/@me/@self'; my $ua = $class->get_useragent; - my $res = $ua->get($url); + my $res = $ua->get( $url, 'Authorization' => 'OAuth ' . $access_token ); unless ( $res->is_success ) { require Data::Dumper; Modified: trunk/cgi-bin/LJ/Identity/Google.pm =================================================================== --- trunk/cgi-bin/LJ/Identity/Google.pm 2011-05-03 06:56:52 UTC (rev 10465) +++ trunk/cgi-bin/LJ/Identity/Google.pm 2011-05-03 07:06:33 UTC (rev 10466) @@ -40,11 +40,12 @@ my $forwhat = $opts{'forwhat'} || 'login'; - my $callback_url = "$LJ::SITEROOT/identity/callback-google.bml?" . - 'forwhat=' . $forwhat; + my $callback_url = "$LJ::SITEROOT/identity/callback-google.bml"; + LJ::Request->set_cookie( 'identity_login_forwhat' => $forwhat ); + my $addr = 'https://accounts.google.com/o/oauth2/auth?' - . 'scope=' . LJ::eurl('https://www.google.com/m8/feeds/') . '&' + . 'scope=' . LJ::eurl('https://www-opensocial.googleusercontent.com/api/people') . '&' . 'client_id=' . $LJ::GOOGLE_OAUTH_CONF->{'client_id'} . '&' . 'redirect_uri=' . LJ::eurl($callback_url) . '&' . 'response_type=code'; @@ -93,10 +94,12 @@ LJ::update_user( $u, { 'name' => $name } ); # userpic - my $upidata = $ua->get( $userinfo->{'thumbnailUrl'} )->content; + if ( my $thumb_url = $userinfo->{'thumbnailUrl'} ) { + my $upidata = $ua->get( $thumb_url )->content; - my $userpic = eval { LJ::Userpic->create($u, data => \$upidata) }; - $userpic->make_default if $userpic; + my $userpic = eval { LJ::Userpic->create( $u, 'data' => \$upidata ) }; + $userpic->make_default if $userpic; + } # website $u->set_prop( 'url' => $link ); Modified: trunk/htdocs/identity/callback-google.bml =================================================================== --- trunk/htdocs/identity/callback-google.bml 2011-05-03 06:56:52 UTC (rev 10465) +++ trunk/htdocs/identity/callback-google.bml 2011-05-03 07:06:33 UTC (rev 10466) @@ -10,7 +10,7 @@ # user will unlikely ever need to see this $title = 'Google Landing Page'; - my $forwhat = LJ::Request->get_param('forwhat') || 'login'; + my $forwhat = LJ::Request->cookie('identity_login_forwhat'); my ($returl, $returl_fail); eval { @@ -46,7 +46,7 @@ } ); my $u = LJ::User::load_identity_user( - 'V', $userinfo->{'id'}, + 'G', $userinfo->{'id'}, { 'token_info' => $token_info, 'userinfo' => $userinfo }, \$created );