-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcallback.php
More file actions
43 lines (34 loc) · 1009 Bytes
/
Copy pathcallback.php
File metadata and controls
43 lines (34 loc) · 1009 Bytes
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
<?php
// Step two: check if user has autorized our app
include_once "../../../autoload.php";
// very small boot file. Starts session. Defines constants.
include_once "boot.php";
// use the githubapi
use diversen\githubapi;
/*
* We are back from github and the user has accepted our
* request. We can now request an access token,
* The simple-php-github-api will just set this as a SESSION var found in
* $_SESSION['access_token'], when we return from github
*
* We check if everything is fine, and redirect to app_call.php
* Here we will we make api calls using the $_SESSION['access_token']
*
* Next step:
*
* /api_call.php
*
*/
$access_config = array (
'redirect_uri' => GITHUB_CALLBACK_URL,
'client_id' => GITHUB_ID,
'client_secret' => GITHUB_SECRET,
);
$api = new githubapi();
$res = $api->setAccessToken($access_config );
if ($res) {
header("Location: /api.php");
} else {
echo "Could not get access token. Errors: <br />";
print_r($api->errors);
}