How to set header for restful api authentication using RESTclient Addon Firefox

php, rest, restful-authentication, yii

Solution

I understand your question (same as this post in yii forum) relates to the RESTClient addon. To set your headers in the RESTClient addon: use the 'headers' functionality:

- List item

- menu 'Headers'

- 'Custom Header'

- 'Name' : X_PASSWORD

- 'Value' : emo

And the same with X_USERNAME.

HTH,

JM.

Problem

I have this code from Yii Example ``` private function _checkAuth() { // Check if we have the USERNAME and PASSWORD HTTP headers set? if(!(isset($_SERVER['HTTP_X_USERNAME']) and isset($_SERVER['HTTP_X_PASSWORD']))) { // Error: Unauthorized $this->_sendResponse(401); } $username = $_SERVER['HTTP_X_USERNAME']; $password = $_SERVER['HTTP_X_PASSWORD']; // Find the user $user=User::model()->find('LOWER(username)=?',array(strtolower($username))); $this->_sendResponse('200','$username'); if($user===null) { // Error: Unauthorized $this->_sendResponse(401, 'Error: User Name is invalid'); } else if(!$user->validatePassword($password)) { // Error: Unauthorized $this->_sendResponse(401, 'Error: User Password is invalid'); } } ``` How to set header information for authentication. How to set HTTP_X_USERNAME and HTTP_X_PASSWORD in request; for the name, value and body of RESTClient addon? Thank for advance

Original source