-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathimgupload.php
39 lines (27 loc) · 917 Bytes
/
imgupload.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
require_once 'vendor/autoload.php';
$Clientid="20878488570-mns7uv14508g43d6ro7j72meuon9496j.apps.googleusercontent.com";
$Clientsectret="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";
$redirec="http://localhost/myimdb/home.php";
//creating request to google
$Client= new Google_Client();
$Client->setClientId($Clientid);
$Client->setClientSecret($Clientsectret);
$Client->setRedirectUri($redirec);
$Client->addScope('profile');
$Client->addScope('email');
if(isset($_GET['code']))
{
// echo $_GET['code'];
$token=$Client->fetchAccessTokenWithAuthCode($_GET['code']);
$Client->setAccessToken($token['access_token']);
$gauth=new Google_Service_Oauth2($Client);
$google_info=$gauth->userinfo->get();
$email=$google_info->email;
$name=$google_info->name;
echo 'wellcome '.$name.' you are logged in with email id: '.$email;
}
else{
echo '<a href="'.$Client->createAuthUrl().'"> login with google</a>';
}
?>