Skip to content

OAuth server sends a 401 response where it should be 403 #254

@marovelo

Description

@marovelo

Hi,
when I send a resource request with an insufficient scope I get the right error and error description:

{"error":"insufficient_scope","error_description":"The request requires higher privileges than provided by the access token"}

However I would expect a 403 response but the response code is 401.
With some debugging I found out that everything works fine when I comment out this line in ResourceController->verifyResourceRequest(...)

$response->addHttpHeaders(array(
                'WWW-Authenticate' => sprintf('%s realm="%s", scope="%s", error="%s", error_description="%s"',
                    $this->tokenType->getTokenType(),
                    $this->config['www_realm'],
                    $scope,
                    $response->getParameter('error'),
                    $response->getParameter('error_description')
                )
            ));

In the line above this one the http code gets set to 403. So it seems that somehow the code gets set to 401 by the addHttpHeaders(...) method.

Some more information:
The problem only occurs when I send a curl request. I also implemented a Silex Web Test Case and here everything works just fine.
I use v0.9 of your implmentation.

Thanks in advance for your help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions