Modules

OAuth2_Provider_Github
extends OAuth2_Provider

OAuth v2 Provider GitHub

package
Gleez\OAuth
author
Sandeep Sangamreddi - Gleez
copyright
© 2011-2013 Gleez Technologies
license
http://gleezcms.org/license

Class declared in MODPATH/user/classes/oauth2/provider/github.php on line 10.

Properties

public $name

Methods

public url_access_token( ) (defined in OAuth2_Provider_Github)

Source Code

public function url_access_token()
{
	return 'https://github.com/login/oauth/access_token';
}

public url_authorize( ) (defined in OAuth2_Provider_Github)

Source Code

public function url_authorize()
{
	return 'https://github.com/login/oauth/authorize';
}

public access_token( ) (defined in OAuth2_Provider)

Source Code

public function access_token(OAuth2_Client $client, $code, array $params = NULL)
{
	$request = OAuth2_Request::factory('token', 'POST', $this->url_access_token(), array(
		'grant_type'    => 'authorization_code',
		'code'          => $code,
		'client_id'     => $client->id,
		'client_secret' => $client->secret,
	));

	if ($client->callback)
	{
		$request->param('redirect_uri', $client->callback);
	}

	if ($params)
	{
		// Load user parameters
		$request->params($params);
	}

	$response = $request->execute();

	//Session::instance()->set('refresh_token', $response->param('refresh_token') );

	return OAuth2_Token::factory('access', array(
		'token' => $response->param('access_token')
	));
}

public authorize_url( ) (defined in OAuth2_Provider)

Source Code

public function authorize_url(OAuth2_Client $client, array $params = NULL)
{
	// Create a new GET request for a request token with the required parameters
	$request = OAuth2_Request::factory('authorize', 'GET', $this->url_authorize(), array(
		'response_type' => 'code',
		'client_id'     => $client->id,
		'redirect_uri'  => $client->callback,
	));

	if ($params)
	{
		// Load user parameters
		$request->params($params);
	}

	return $request->as_url();
}

public static factory( ) (defined in OAuth2_Provider)

Source Code

public static function factory($name, array $options = NULL)
{
	$class = 'OAuth2_Provider_'.$name;

	return new $class($options);
}

public get_tokens( ) (defined in OAuth2_Provider)

Source Code

public function get_tokens(OAuth2_Client $client, $code, array $params = NULL)
{
	$request = OAuth2_Request::factory('token', 'POST', $this->url_access_token(), array(
		'grant_type'    => 'authorization_code',
		'code'          => $code,
		'client_id'     => $client->id,
		'client_secret' => $client->secret,
	));

	if ($client->callback)
	{
		$request->param('redirect_uri', $client->callback);
	}

	if ($params)
	{
		// Load user parameters
		$request->params($params);
	}

	return $request->execute();
}

public url_refresh_token( ) (defined in OAuth2_Provider)

Source Code

public function url_refresh_token()
{
	// By default its the same as access token URL
	return $this->url_access_token();
}
Documentation comments powered by Disqus