Class MOXMAN_Auth_Oauth2


This class wrapps Oauth2 protocols.

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__construct() Constructs a new Oauth2 instance. MOXMAN_Auth_Oauth2
authorize() First step in auth MOXMAN_Auth_Oauth2
refresh() Refresh access_token MOXMAN_Auth_Oauth2
request() Request target by url MOXMAN_Auth_Oauth2
setToken() Set Auth Token Manually MOXMAN_Auth_Oauth2
sign() Sign request MOXMAN_Auth_Oauth2
validate() Validate token MOXMAN_Auth_Oauth2

Method Details

__construct() public method

Constructs a new Oauth2 instance.

public void __construct ( $config )
$config Array

Config options.

Required options $config["auth_url"] = ""; $config["scope"] = ""; $config["callback"] = "http://callbackurl"; $config["client_id"] = "ID"; $config["client_secret"] = "SECRET"; $config["token_url"] = ""; $config["response_type"] = "code"; $config["state"] = "service_name";

authorize() public method

First step in auth

public void authorize ( $force false )
$force Bool

True/false to force user interaction or not.

refresh() public method

Refresh access_token

public void refresh ( )
request() public method

Request target by url

public string request ( $url, $method, $data false )
$url string

URL Target.

$data Array

Optional, data to send to target in POST.

return string

Response of request to target.

setToken() public method

Set Auth Token Manually

public void setToken ( $token )
$token string

Access Token.

sign() public method

Sign request

public Object sign ( $request )
$request Object

Request object to add header too.

return Object

Request object with added header.

validate() public method

Validate token

public void validate ( $token )
$token string

Token should be gotten by $_GET["code"] from redirect.