Окунев Дмитрий Юрьевич

Fixed server URL

Showing 1 changed file with 79 additions and 79 deletions
1 -<? 1 +<?
2 -/* 2 +/*
3 - OAuth2 auth client lib for NRNU MEPhI 3 + OAuth2 auth client lib for NRNU MEPhI
4 - 4 +
5 - Copyright (C) 2014, Dmitry Y Okunev <dyokunev@ut.mephi.ru> 5 + Copyright (C) 2014, Dmitry Y Okunev <dyokunev@ut.mephi.ru>
6 - 6 +
7 - This program is free software; you can redistribute it and/or modify 7 + This program is free software; you can redistribute it and/or modify
8 - it under the terms of the GNU General Public License as published by 8 + it under the terms of the GNU General Public License as published by
9 - the Free Software Foundation; either version 2 of the License, or 9 + the Free Software Foundation; either version 2 of the License, or
10 - (at your option) any later version. 10 + (at your option) any later version.
11 - 11 +
12 - This program is distributed in the hope that it will be useful, 12 + This program is distributed in the hope that it will be useful,
13 - but WITHOUT ANY WARRANTY; without even the implied warranty of 13 + but WITHOUT ANY WARRANTY; without even the implied warranty of
14 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 - GNU General Public License for more details. 15 + GNU General Public License for more details.
16 - 16 +
17 - You should have received a copy of the GNU General Public License along 17 + You should have received a copy of the GNU General Public License along
18 - with this program; if not, write to the Free Software Foundation, Inc., 18 + with this program; if not, write to the Free Software Foundation, Inc.,
19 - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 -*/ 20 +*/
21 -/* 21 +/*
22 - * D Y Okunev <xai@mephi.ru>: Sorry for this code. As always, no time to do something good :( 22 + * D Y Okunev <xai@mephi.ru>: Sorry for this code. As always, no time to do something good :(
23 - * 23 + *
24 - */ 24 + */
25 - 25 +
26 -define("OAUTH2_LIB_DIR", __DIR__ . "/3rdparty/oauth_2.0_client_php"); 26 +define("OAUTH2_LIB_DIR", __DIR__ . "/3rdparty/oauth_2.0_client_php");
27 -require_once OAUTH2_LIB_DIR . "/OAuth2/Exception.php"; 27 +require_once OAUTH2_LIB_DIR . "/OAuth2/Exception.php";
28 - 28 +
29 -define('OAUTH2_URL', 'https://oauth2.ut.mephi.ru/'); 29 +define('OAUTH2_URL', 'https://oauth2.mephi.ru/');
30 - 30 +
31 -class OAuth2_MEPhI { 31 +class OAuth2_MEPhI {
32 - private $client_id = NULL; 32 + private $client_id = NULL;
33 - private $client = NULL; 33 + private $client = NULL;
34 - private $configuration = NULL; 34 + private $configuration = NULL;
35 - private $storage = NULL; 35 + private $storage = NULL;
36 - private $service = NULL; 36 + private $service = NULL;
37 - private $scope = NULL; 37 + private $scope = NULL;
38 - 38 +
39 - function __construct($client_id, $client_secret, $backurl) { 39 + function __construct($client_id, $client_secret, $backurl) {
40 - require_once OAUTH2_LIB_DIR . "/OAuth2/Client.php"; 40 + require_once OAUTH2_LIB_DIR . "/OAuth2/Client.php";
41 - $this->client_id = $client_id; 41 + $this->client_id = $client_id;
42 - 42 +
43 - $this->client = new OAuth2\Client( 43 + $this->client = new OAuth2\Client(
44 - $client_id, 44 + $client_id,
45 - $client_secret, 45 + $client_secret,
46 - $backurl 46 + $backurl
47 - ); 47 + );
48 - 48 +
49 - require_once OAUTH2_LIB_DIR . "/OAuth2/Service/Configuration.php"; 49 + require_once OAUTH2_LIB_DIR . "/OAuth2/Service/Configuration.php";
50 - $this->configuration = new OAuth2\Service\Configuration( 50 + $this->configuration = new OAuth2\Service\Configuration(
51 - OAUTH2_URL.'authorize.php', 51 + OAUTH2_URL.'authorize.php',
52 - OAUTH2_URL.'token.php' 52 + OAUTH2_URL.'token.php'
53 - ); 53 + );
54 - $this->configuration->setAuthorizationMethod(OAuth2\Service\Configuration::AUTHORIZATION_METHOD_ALTERNATIVE); 54 + $this->configuration->setAuthorizationMethod(OAuth2\Service\Configuration::AUTHORIZATION_METHOD_ALTERNATIVE);
55 - 55 +
56 - require_once OAUTH2_LIB_DIR . "/OAuth2/DataStore.php"; 56 + require_once OAUTH2_LIB_DIR . "/OAuth2/DataStore.php";
57 - require_once OAUTH2_LIB_DIR . "/OAuth2/DataStore/Session.php"; 57 + require_once OAUTH2_LIB_DIR . "/OAuth2/DataStore/Session.php";
58 - $this->storage = new OAuth2\DataStore\Session(); 58 + $this->storage = new OAuth2\DataStore\Session();
59 - 59 +
60 - require_once OAUTH2_LIB_DIR . "/OAuth2/Service.php"; 60 + require_once OAUTH2_LIB_DIR . "/OAuth2/Service.php";
61 - $this->service = new OAuth2\Service($this->client, $this->configuration, $this->storage, $this->scope); 61 + $this->service = new OAuth2\Service($this->client, $this->configuration, $this->storage, $this->scope);
62 - } 62 + }
63 - 63 +
64 - function get_token() { 64 + function get_token() {
65 - require_once OAUTH2_LIB_DIR . "/OAuth2/Token.php"; 65 + require_once OAUTH2_LIB_DIR . "/OAuth2/Token.php";
66 - require_once OAUTH2_LIB_DIR . "/OAuth2/HttpClient.php"; 66 + require_once OAUTH2_LIB_DIR . "/OAuth2/HttpClient.php";
67 - $this->service->getAccessToken(); 67 + $this->service->getAccessToken();
68 - 68 +
69 - return json_decode($this->service->callApiEndpoint(OAUTH2_URL.'token_data.php')); 69 + return json_decode($this->service->callApiEndpoint(OAUTH2_URL.'token_data.php'));
70 - } 70 + }
71 - 71 +
72 - function check_if_authed() { 72 + function check_if_authed() {
73 - header('Location: '.OAUTH2_URL.'authorize.php?cmd=check&client_id='.$this->client_id.'&response_type=code&state=authentication'); 73 + header('Location: '.OAUTH2_URL.'authorize.php?cmd=check&client_id='.$this->client_id.'&response_type=code&state=authentication');
74 - return NULL; 74 + return NULL;
75 - } 75 + }
76 - 76 +
77 -} 77 +}
78 - 78 +
79 -?> 79 +?>