hello guys i am new here and i want to know about how can i get the user details after sign_in from my app by using google sign_in method with core php. All i want to know is that when i logged in with my google id from third party login in my app i want Json data of user profile detail.
I have tried the socialite and get the solution but i do want it to get done with core php method
Here is my redirect to google method :-
public function redirectToGoogle()
{
$url = 'https://accounts.google.com/o/oauth2/v2/auth?scope='.urlencode('https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email').'&redirect_uri='.urlencode(env('GOOGLE_REDIRECT')) . '&response_type=code&client_id=' . env('GOOGLE_CLIENT_ID') . '&access_type=online';
   return redirect($url);
}
And this is my callback method:-
public function callback(Request $request)
{
  $url = $request->getRequestUri();
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_URL,$url);
  $result=curl_exec($ch);
  curl_close($ch);
  var_dump(json_decode($result, true));
}
From this code i get null value as output, but i accepted json data of logged in user as result
via Chebli Mohamed
 
Aucun commentaire:
Enregistrer un commentaire