-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcallback_1.php
More file actions
92 lines (75 loc) · 3.14 KB
/
callback_1.php
File metadata and controls
92 lines (75 loc) · 3.14 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!DOCTYPE html>
<html>
<head>
<title>oAuth</title>
<link rel="stylesheet" type="text/css" href="newcss.css" />
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
<link rel="icon" type="image/png" href="/favicon-32x32.png"/>
<link rel="icon" type="image/png" href="/favicon-16x16.png"/>
<link rel="manifest" href="/manifest.json" />
<link rel="mask-icon" href="/safari-pinned-tab.svg"/>
</head>
<body>
<?php
//if people find their way here, give them a way to get back home
echo '<a href="index.php">GO HOME YOU ARE DRUNK<br /></a>';
require_once 'vendor/autoload.php';
$oauth_code = $_GET['code'];
$oauth_state = $_GET['state'];
$skip_yes = 0;
if ($oauth_code . $oauth_state == null) {
$skip_yes = 1;
goto skip;
}
require_once 'vendor/autoload.php';
include('auth.php');
$grant_type = "authorization_code";
$oauth_client_id = "2d9e5cbc5d888bef3253c0489d6851f5";
$oauth_client_secret = "249046db0fd92da7ddcbd1487feb7246";
$client = new HelloSign\Client($api_key);
$request = new HelloSign\OAuthTokenRequest(array(
'code' => "$oauth_code",
'state' => "$oauth_state",
'client_id' => "$oauth_client_id",
'client_secret' => "$oauth_client_secret"
));
$token_response = $client->requestOAuthToken($request);
print_r($token_response->access_token);
echo("HOLY SHIT THE TOKEN'S HERE!!");
$sendgrid_apikey = getenv('SENDGRID_PHP_APIKEY') ? getenv('SENDGRID_PHP_APIKEY') : '';
$sendgrid = new SendGrid($sendgrid_apikey);
$url = 'https://api.sendgrid.com/';
$pass = $sendgrid_apikey;
$params = array(
'to' => "radhack242+oauth@gmail.com",
'toname' => "oAuth Page Hit",
'from' => "radhack242@gmail.com",
'fromname' => "oAuth Page was hit",
'subject' => "oAuth Page was hit",
'html' => "<strong>$oauth_code</strong><br />Is the oauth code<br />$oauth_state is the state.<br />",
);
$request = $url . 'api/mail.send.json';
// Generate curl request
$session = curl_init($request);
// Tell PHP not to use SSLv3 (instead opting for TLS)
curl_setopt($session, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
curl_setopt($session, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $sendgrid_apikey));
// Tell curl to use HTTP POST
curl_setopt($session, CURLOPT_POST, true);
// Tell curl that this is the body of the POST
curl_setopt($session, CURLOPT_POSTFIELDS, $params);
// Tell curl not to return headers, but do return the response
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
// obtain response
$response = curl_exec($session);
curl_close($session);
// print everything out
// print_r($response);
skip:
if ($skip_yes == 1) {
echo "You didn't enter the magic words<br />";
}
?>
</body>
</html>