-
-
Save kiall/1169681 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php defined('SYSPATH') or die('No direct script access.'); | |
class Controller_Test2 { | |
public function action_index() | |
{ | |
// State can be used to bring the user back to where they originally were before the redirect.. | |
$state = json_decode($this->request->query('state')); | |
// Load up the right consumer | |
$client = OAuth2_Consumer::factory('mip'); | |
// Store the client token/refresh token | |
$client->exchange_code_for_token($this->request, 1); | |
echo 'Have a token now .. try again'; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php defined('SYSPATH') or die('No direct script access.'); | |
/** | |
* | |
* | |
* @category Controller | |
* @author Managed I.T. | |
* @copyright (c) 2011 Managed I.T. | |
*/ | |
class Controller_Test extends Controller { | |
public function action_index() | |
{ | |
try | |
{ | |
$client = OAuth2_Consumer::factory('mip'); | |
$request = Request::factory('http://wk01-lmst.managedit.ie/mip-api/api/roles'); | |
$response = json_decode($client->execute($request, 1)); | |
echo Debug::vars($response); | |
} | |
catch (OAuth2_Exception_InvalidToken $e) | |
{ | |
$state = 'some_state_to_be_passed_through_the_authorize_request'; | |
$this->request->redirect($client->authorize_url($state)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment