public function authenticate()
	{
		if ($data['code'] = $this->input->get('code', false, 'raw'))
		{
			$data['grant_type'] = 'authorization_code';
			$data['redirect_uri'] = $this->getOption('redirecturi');
			$data['client_id'] = $this->getOption('clientid');
			$data['client_secret'] = $this->getOption('clientsecret');
			$response = $this->http->post($this->getOption('tokenurl'), $data);

			if ($response->code >= 200 && $response->code < 400)
			{
				if ($response->headers['Content-Type'] == 'application/json')
				{
					$token = array_merge(json_decode($response->body, true), array('created' => time()));
				}
				else
				{
					parse_str($response->body, $token);
					$token = array_merge($token, array('created' => time()));
				}

				$this->setToken($token);

				return $token;
			}
			else
			{
				throw new \RuntimeException('Error code ' . $response->code . ' received requesting access token: ' . $response->body . '.');
			}
		}

		if ($this->getOption('sendheaders'))
		{
			$this->application->redirect($this->createUrl());
		}

		return false;
	}
public function authenticate()
	{
		if ($data['code'] = $this->input->get('code', false, 'raw'))
		{
			$data['grant_type'] = 'authorization_code';
			$data['redirect_uri'] = $this->getOption('redirecturi');
			$data['client_id'] = $this->getOption('clientid');
			$data['client_secret'] = $this->getOption('clientsecret');
			$response = $this->http->post($this->getOption('tokenurl'), $data);

			if ($response->code >= 200 && $response->code < 400)
			{
				if ($response->headers['Content-Type'] == 'application/json')
				{
					$token = array_merge(json_decode($response->body, true), array('created' => time()));
				}
				else
				{
					parse_str($response->body, $token);
					$token = array_merge($token, array('created' => time()));
				}

				$this->setToken($token);

				return $token;
			}
			else
			{
				throw new \RuntimeException('Error code ' . $response->code . ' received requesting access token: ' . $response->body . '.');
			}
		}

		if ($this->getOption('sendheaders'))
		{
			$this->application->redirect($this->createUrl());
		}

		return false;
	}
public function authenticate ( ) { if ( $ data [ 'code' ] = $ this -> input -> get ( 'code' , false , 'raw' ) ) { $ data [ 'grant_type' ] = 'authorization_code' ; $ data [ 'redirect_uri' ] = $ this -> getOption ( 'redirecturi' ) ; $ data [ 'client_id' ] = $ this -> getOption ( 'clientid' ) ; $ data [ 'client_secret' ] = $ this -> getOption ( 'clientsecret' ) ; $ response = $ this -> http -> post ( $ this -> getOption ( 'tokenurl' ) , $ data ) ; if ( $ response -> code >= 200 && $ response -> code < 400 ) { if ( $ response -> headers [ 'Content-Type' ] == 'application/json' ) { $ token = array_merge ( json_decode ( $ response -> body , true ) , array ( 'created' => time ( ) ) ) ; } else { parse_str ( $ response -> body , $ token ) ; $ token = array_merge ( $ token , array ( 'created' => time ( ) ) ) ; } $ this -> setToken ( $ token ) ; return $ token ; } else { throw new \ RuntimeException ( 'Error code ' . $ response -> code . ' received requesting access token: ' . $ response -> body . '.' ) ; } } if ( $ this -> getOption ( 'sendheaders' ) ) { $ this -> application -> redirect ( $ this -> createUrl ( ) ) ; } return false ; }
Get the access token or redict to the authentication URL.

@return  string  The access token

@since   1.0
@throws  \RuntimeException
Get the access token or redict to the authentication URL .