-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreturn.php
33 lines (23 loc) · 993 Bytes
/
return.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
<?php
include 'config.php';
session_start();
$_SESSION['keylead_code']=$_GET['code'];
$url = $config['sso'].'/token/';
$ch = curl_init($url);
//TODO : remove this
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$fields = "client_id=".$config['client_id']."&client_secret=".$config['client_secret']."&code=".$_GET['code']."&redirect_uri=".$config['home']."return.php&grant_type=authorization_code";
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
$response = curl_exec($ch);
if ($response === false) {
throw new Exception(curl_error($ch), curl_errno($ch));
}
curl_close($ch);
$token = json_decode($response);
$_SESSION['access_token']= $token->access_token;
$_SESSION['refresh_token']= $token->refresh_token;
header("Location: {$config['home']}index.php");