neattutorials / angularjs-yii2-part-2-authentication

http://blog.neattutorials.com/angularjs-and-yii2-part-2-authentication/
Other
28 stars 23 forks source link

You are requesting with an invalid credential. #5

Open shivpareek opened 8 years ago

shivpareek commented 8 years ago

Hi,

Can anybody help me ... I am getting 401 error. The error response is: {"name":"Unauthorized","message":"You are requesting with an invalid credential.","code":0,"status":401,"type":"yii\web\UnauthorizedHttpException"}

I am using same code and after login it returning me access_token but after login it redirect me to login with 401 Error

I debug with code step by step and finally i got this:

In "yii\filters\auth\HttpBearerAuth" class "authenticate" method is returning me null ... I print value for "$request->getHeaders()->get('Authorization')" and its return me blank.

can anybody know this why?

Thanks

shivpareek commented 8 years ago

Thanks to @nadar

Here is the solution https://github.com/yiisoft/yii2/issues/6631

nadar commented on Jan 20, 2015

We have fixed the problem. The problem appears if you'r using CGI/FastCGI mode. As mentioned in the php comments (http://php.net/manual/en/features.http-auth.php#114877) you can put

SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0

in the .htaccess file to make Authorizaion variable available.