public function authenticate(HTTPRequest $request)
    {
        //get the token
        $token = $request->getHeader($this->tokenConfig['header']);
        if (!$token) {
            $token = $request->requestVar($this->tokenConfig['queryVar']);
        }

        if ($token) {
            //check token validity
            return $this->validateAPIToken($token, $request);
        } else {
            //no token, bad news
            return new RESTfulAPIError(403,
                'Token invalid.',
                array(
                    'message' => 'Token invalid.',
                    'code' => self::AUTH_CODE_TOKEN_INVALID,
                )
            );
        }
    }
public function authenticate(HTTPRequest $request)
    {
        //get the token
        $token = $request->getHeader($this->tokenConfig['header']);
        if (!$token) {
            $token = $request->requestVar($this->tokenConfig['queryVar']);
        }

        if ($token) {
            //check token validity
            return $this->validateAPIToken($token, $request);
        } else {
            //no token, bad news
            return new RESTfulAPIError(403,
                'Token invalid.',
                array(
                    'message' => 'Token invalid.',
                    'code' => self::AUTH_CODE_TOKEN_INVALID,
                )
            );
        }
    }
public function authenticate ( HTTPRequest $ request ) { //get the token $ token = $ request -> getHeader ( $ this -> tokenConfig [ 'header' ] ) ; if ( ! $ token ) { $ token = $ request -> requestVar ( $ this -> tokenConfig [ 'queryVar' ] ) ; } if ( $ token ) { //check token validity return $ this -> validateAPIToken ( $ token , $ request ) ; } else { //no token, bad news return new RESTfulAPIError ( 403 , 'Token invalid.' , array ( 'message' => 'Token invalid.' , 'code' => self :: AUTH_CODE_TOKEN_INVALID , ) ) ; } }
Checks if a request to the API is authenticated
Gets API Token from HTTP Request and return Auth result

@param  HTTPRequest           $request    HTTP API request
@return true|RESTfulAPIError                True if token is valid OR RESTfulAPIError with details
Checks if a request to the API is authenticated Gets API Token from HTTP Request and return Auth result