N
N
nepster-web2015-09-02 20:13:53
PHP
nepster-web, 2015-09-02 20:13:53

How to get oauth2 token using UserCredentials method?

I'm trying to screw oauth2. I'm interested in the type of authentication namely user-credentials: https://bshaffer.github.io/oauth2-server-php-docs/... That is, by login and password.
Copy-paste from the docks:

$users = array('bshaffer' => array('password' => 'brent123', 'first_name' => 'Brent', 'last_name' => 'Shaffer'));
$storage = new \OAuth2\Storage\Memory(array('user_credentials' => $users));
$grantType = new \OAuth2\GrantType\UserCredentials($storage);

$server = new \OAuth2\Server($storage);
$server->addGrantType($grantType);
$server->handleTokenRequest(\OAuth2\Request::createFromGlobals())->send();

Server response:
{"error":"invalid_client","error_description":"Client credentials were not found in the headers or body"}

For example, everything works in the Client Credentials type. But it is necessary through the login and password.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nepster-web, 2015-09-03
@nepster-web

This library obliges to transfer also client_id and client_secret

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question