Two-Legged Oauth2 With Yii2

Yii Guide claims to support OAuth2 among others in Rest and here I quote

Now I need to make API for a mobile app. I have checked ther Token bearer and seems to me its more of client thing than a server thing. Anyone that can help me get right direction on making two legged OAuth2.

All I need is to authenticate app and then user, and then generate token which will persist until expiry and refresh token for regenerating the token again.

Any method?


have you got a solution?

Api example is here

and oAuth2 should be added to it.

Anyone ever used

Have you know how to use that extension, Stefano?

I tried and made it work on generating token nothing more!

I’m also attempting to implement OAuth2 authentication in the API I’m implementing using Yii2. It seems the guide in the library is lacking instructions. Maybe someone has implemented OAuth2 in Yii2 successfully?

Hi all.

I decided to reply here too for searchers!

I’ve create yii2 template with configured Two-Legged OAuth 2 server.

You can find it here:

This template have configured extension, structure to quick start develop RESTful API and some test data to see how it works.

Also exists docker image for quick look (read description to repo).

Great sir. Do you mind writing a tutorial on how to use yii2-oauth-server?

That will be plus for those who want to use your extension!


I’ve described usage in repository’s description. It’s include:

  • Run in Docker

  • Installation

  • Confiration

  • Structure

  • Tests with conditions, description and curl requests

I can duplicate information here, but I think it doesn’t make a sense.

Maybe you have some questions after reading repo’s description or any problems - feel free to ask.

Also, maybe I missed something to describe - I could add it, if you tell me about it.

First you have done a great deal of job, I appreciate that. I was not asking you duplicate it here, no! I was asking for simple tutorial on how the yii2-oauth2-server works.

That will help beginners and hence add contributors. As per its github issues, amny are asking for this. So tutorial+sample(which you have done a good job there) will make a good documentation!