D
D
Denis2018-03-25 12:05:00
Yii
Denis, 2018-03-25 12:05:00

Create bearer token programmatically?

I decided to make a mini API for the application, and so the question took the extension https://github.com/Filsh/yii2-oauth2-server
as a base , and so the question is: how to create a token programmatically? that is, I register a user through the API and want to return the token immediately, without sending a request to /oauth2/token. UPD, I decided to write a stupidly random string to the database and it seems to be rolling, but I feel there is a catch somewhere

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly, 2020-06-22
@vkopytov

$module = Yii::$app->getModule('oauth2');
$token = $module->getServer()->createAccessToken("testclient", $user_id, 'default', true);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question