Failed to authenticate the user when sending a POST request


(Wang Wuhuang) #1

I set the $behaviors[‘authenticator’] to be ”QueryParamAuth“ in my controller class,when I send a GET request with a token in curl,everything works just fine.

But when I send a POST request with a token in the body of curl,error ocurred.

Then I set the $behaviors[‘authenticator’] to be CompositeAuth,and define “HttpBasicAuth”、“ HttpBearerAuth”、“ QueryParamAuth” as ‘authMethods’,

I send the POST request for the second time,nothing changed.

Any help?what should I do if I want to make the authentication works when sending a POST request? Thanks in advance. :rolleyes:


(Soyhobo) #2

You should post some code, and perhaps your request and response. Have you tried a web browser based http client like postman?

Did you check the guide recently? http://www.yiiframework.com/doc-2.0/guide-rest-authentication.html