@@ -78,28 +78,34 @@ public function authenticatedRequest(Google_Http_Request $request)
7878
7979 /**
8080 * @param string $code
81+ * @param boolean $crossClient
8182 * @throws Google_Auth_Exception
8283 * @return string
8384 */
84- public function authenticate ($ code )
85+ public function authenticate ($ code, $ crossClient )
8586 {
8687 if (strlen ($ code ) == 0 ) {
8788 throw new Google_Auth_Exception ("Invalid code " );
8889 }
8990
91+ $ arguments = array (
92+ 'code ' => $ code ,
93+ 'grant_type ' => 'authorization_code ' ,
94+ 'client_id ' => $ this ->client ->getClassConfig ($ this , 'client_id ' ),
95+ 'client_secret ' => $ this ->client ->getClassConfig ($ this , 'client_secret ' )
96+ );
97+
98+ if ($ crossClient !== true ) {
99+ $ arguments ['redirect_uri ' ] = $ this ->client ->getClassConfig ($ this , 'redirect_uri ' );
100+ }
101+
90102 // We got here from the redirect from a successful authorization grant,
91103 // fetch the access token
92104 $ request = new Google_Http_Request (
93105 self ::OAUTH2_TOKEN_URI ,
94106 'POST ' ,
95107 array (),
96- array (
97- 'code ' => $ code ,
98- 'grant_type ' => 'authorization_code ' ,
99- 'redirect_uri ' => $ this ->client ->getClassConfig ($ this , 'redirect_uri ' ),
100- 'client_id ' => $ this ->client ->getClassConfig ($ this , 'client_id ' ),
101- 'client_secret ' => $ this ->client ->getClassConfig ($ this , 'client_secret ' )
102- )
108+ $ arguments
103109 );
104110 $ request ->disableGzip ();
105111 $ response = $ this ->client ->getIo ()->makeRequest ($ request );
0 commit comments