-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
37 lines (28 loc) · 1016 Bytes
/
index.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
<?php
ini_set('display_errors',true);
require_once 'vendor/autoload.php';
use \Symfony\Component\HttpFoundation\Request;
use \Symfony\Component\HttpFoundation\Response;
use OauthClient\Service\ClientService;
use OauthClient\Config;
$app = new Silex\Application();
$app['debug'] = true;
$clientId = '53712880555-5llqustj9g6trps9h49pila1191sa9p7.apps.googleusercontent.com';
$clientSecret = 'ih75vHw-4_TUSxaISvYqLUsw';
$redirectUrl = 'http://git-oauth.dev/index.php/oauth2callback';
$service = new ClientService(
new Config('google', $clientId, $clientSecret, $redirectUrl)
);
$app->get('/', function() use($app, $service) {
return $app->redirect($service->getAuthUrl());
return new Response();
});
$app->get('/oauth2callback', function(Request $request) use($app, $service) {
$code = $request->get('code');
//if($service->authenticate($code)){
// $service->getUserInfo();
//Do anything after that
//}
return new Response();
});
$app->run();