google login
This commit is contained in:
@@ -157,6 +157,30 @@ class WrenchOauth extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
private function gooleOAuthGetUser($access_token, &$local_out) {
|
||||
|
||||
$urlInfp = "https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token=" . $access_token;
|
||||
|
||||
$ch = curl_init();
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL,$urlInfp);
|
||||
//curl_setopt($ch, CURLOPT_POST, 1);
|
||||
//curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
|
||||
// Receive server response ...
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
$server_output = curl_exec($ch);
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
$local_out = json_decode($server_output,true);
|
||||
|
||||
if (!is_array($local_out) || !array_key_exists("message",$local_out)) {
|
||||
$local_out["message"] = "Received from Google token API: ".$server_output;
|
||||
}
|
||||
return $local_out;
|
||||
}
|
||||
private function prepareOauthEndPointData($endpoint, $in, &$call_backend=true,&$local_out=[]){
|
||||
log_message('critical', "Started prepareOauthEndPointData -> ".$endpoint );
|
||||
switch ($endpoint) {
|
||||
@@ -173,6 +197,15 @@ class WrenchOauth extends BaseController
|
||||
break;
|
||||
case 'authlogin':
|
||||
// not really implemented
|
||||
|
||||
switch($in["auth_type"]){
|
||||
case 'GOOGLE':
|
||||
log_message('critical', "prepareOauthEndPointDataL LOGIN DATA STEP 2".serialize($in) );
|
||||
$this->gooleOAuthGetUser($in["access_token"], $local_out);
|
||||
log_message('critical', "prepareOauthEndPointDataL FINAL DATALOGIN DATA STEP 3".serialize($local_out) );
|
||||
break;
|
||||
}
|
||||
|
||||
$in["action"] = WRENCHBOARD_ACCOUNT_AUXLOGIN;
|
||||
if (!isset($in["login_mode"])){
|
||||
$in["login_mode"] = MOBILE_LOGIN;
|
||||
|
||||
Reference in New Issue
Block a user