L
L
Lomoson2015-10-28 17:01:27
Yii
Lomoson, 2015-10-28 17:01:27

How to implement authentication in REST API using HttpBearerAuth?

Help, please, to understand in what a problem.
I read rest-authentication.md and write what is indicated there.
Using QueryParamAuth, I added authentication without any problems (because the problem is only in one of the methods, with behaviors, the implementation of the interfaces is all OK), but I just can’t figure out what is wrong with using HttpBearerAuth.
Here's the thing I get:
Www-Authenticate → Bearer2 realm="api"
In the headers should be something like:

header('Authorization: Bearer 0000000000111111111000001');

How to add it there?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Donkovtsev, 2015-10-29
@Demetriy

Install a plug-in in your browser, for example for chrome "Advanced REST client" to make it easier to check. Setting headers depends on how you implement the work with the server side, for the simplest option, obviously, you need to search for the following query in Google: "javascript set headers".
From my recent experience: when developing on a testbed, apache cut off the "Authorization" directive in the headers until I added a special. code in .htaccess

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question