Get support for cebe/yii2-oauth-server-example

If you're new to LTH, please see our FAQ for more information on what it is we do.

Support Options

Unfortunately, there are currently no active helpers for this repository on the platform. Until they become available, we reccomend the following actions:

View Open Issues

Take a look to see if anyone else has experienced the same issue as you and if they managed to solve it.

Open an Issue

Make sure to read any relevant guidelines for opening issues on this repo before posting a new issue.

Sponsor directly

Check out the page and see if there are any options to sponsor this project or it's developers directly.

cebe/yii2-oauth-server-example

yii2-oauth-server-example

Example application to demonstrate the implementation of an OAuth-Server with Yii 2

Getting started

  • $ git clone https://github.com/cebe/yii2-oauth-server-example.git

  • $ cd yii2-oauth-server-example

  • $ composer install

  • create new file config/db.php

  • put content in that file as:

    <?php
    
    return [
        'class' => 'yii\db\Connection',
        'dsn' => 'mysql:host=localhost;dbname=oauth-jwt-server',
        'username' => 'PLACEHOLDER', // replace this
        'password' => 'PLACEHOLDER', // replace this
        'charset' => 'utf8',
    
        // Schema cache options (for production environment)
        //'enableSchemaCache' => true,
        //'schemaCacheDuration' => 60,
        //'schemaCache' => 'cache',
    ];
    
  • adjust DB name, user and password accordingly in above file & make sure you have created above database externally (for e.g. phpmyadmin)

  • hit migration by $ ./yii migrate

  • generate private key $ openssl genrsa -out private.key 2048

  • generate public key $ openssl rsa -in private.key -pubout > public.key

  • above both commands will generate 2 files (public.key & private.key) in project root dir

  • give them necessary permission $ sudo chmod -R 600 public.key private.key (make sure you are present ($ - present working directory) in project root dir (e.g. yii2-oauth-server-example) )

  • start server by $ php -S localhost:7876

  • Note: if you choose different port make corresponding change in file components/OauthServerClient.php in client app (in your local project)

  • visit http://localhost:7876/web/index.php in browser

  • now you should have this web app running in browser

Next step

Notes

  • this example only implements Authorization code grant
  • this app is for only server rendered app (a typical PHP MVC app) and not for SPA (Single page application)
Our Mission

We want to make open source more sustainable. The entire platform was born from this and everything we do is in aid of this.

Interesting Articles

Thank you for checking out LiveTechHelper |
2025 © lth-dev incorporated

p-e622a1a2