holyandrew (holyandrew) wrote in changelog,
holyandrew
holyandrew
changelog

[ljcom] r13118: LJSUP-14790: Can't log in with Google id...

Committer: akanashin
LJSUP-14790: Can't log in with Google identity
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/cgi-bin/LJ/Client/Google.pm
===================================================================
--- trunk/cgi-bin/LJ/Client/Google.pm	2013-01-18 12:34:48 UTC (rev 13117)
+++ trunk/cgi-bin/LJ/Client/Google.pm	2013-01-18 13:30:24 UTC (rev 13118)
@@ -19,7 +19,7 @@
     } elsif ( my $refresh_token = $opts->{'refresh_token'} ) {
         $postdata->{'refresh_token'} = $refresh_token;
         $postdata->{'grant_type'}    = 'refresh_token';
-
+        $postdata->{'scope'}='https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile';
     }
 
     my $ua = $class->get_useragent;
@@ -78,12 +78,11 @@
         $access_token = $class->get_user_access_token($u);
     }
 
-    my $url = 'https://www-opensocial.googleusercontent.com/'
-            . 'api/people/@me/@self';
+    my $url = 'https://www.googleapis.com/oauth2/v1/userinfo';
 
     my $ua = $class->get_useragent;
 
-    my $res = $ua->get( $url, 'Authorization' => 'OAuth ' . $access_token );
+    my $res = $ua->get( $url, 'Authorization' => 'Bearer ' . $access_token );
 
     unless ( $res->is_success ) {
         require Data::Dumper;
@@ -92,8 +91,7 @@
         die 'google connectivity error';
     }
 
-    my $result_hash = LJ::JSON->from_json( $res->content );
-    return $result_hash->{'entry'};
+    return LJ::JSON->from_json( $res->content );
 }
 
 sub get_useragent {

Modified: trunk/cgi-bin/LJ/Identity/Google.pm
===================================================================
--- trunk/cgi-bin/LJ/Identity/Google.pm	2013-01-18 12:34:48 UTC (rev 13117)
+++ trunk/cgi-bin/LJ/Identity/Google.pm	2013-01-18 13:30:24 UTC (rev 13118)
@@ -23,7 +23,7 @@
     LJ::Request->set_cookie( 'identity_login_forwhat' => $forwhat );
 
     my $addr  = 'https://accounts.google.com/o/oauth2/auth?'
-              . 'scope=' . LJ::eurl('https://www-opensocial.googleusercontent.com/api/people') . '&'
+              . 'scope=' . LJ::eurl('https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile') . '&'
               . 'client_id=' . $LJ::GOOGLE_OAUTH_CONF->{'client_id'} . '&'
               . 'redirect_uri=' . LJ::eurl($callback_url) . '&'
               . 'response_type=code';

Modified: trunk/htdocs/identity/callback-google.bml
===================================================================
--- trunk/htdocs/identity/callback-google.bml	2013-01-18 12:34:48 UTC (rev 13117)
+++ trunk/htdocs/identity/callback-google.bml	2013-01-18 13:30:24 UTC (rev 13118)
@@ -51,7 +51,7 @@
         'access_token' => $token_info->{'access_token'},
     } );
 
-    unless ( $userinfo->{'profileUrl'} ) {
+    unless ( $userinfo->{'link'} ) {
         my $redir_url
             = "$LJ::SITEROOT/identity/callback-google.bml?error=no_profile";
         return LJ::Request->redirect( $redir_url );

Tags: akanashin, bml, holyandrew, ljcom, pm
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments