GithubHelp home page GithubHelp logo

Comments (9)

hiqsol avatar hiqsol commented on July 16, 2024 16

This is how I solved the problem through configuration.
It's a bit rude but requires no chages to this package.

    'modules' => [ 
        'oauth2' => [ 
            'class' => \filsh\yii2\oauth2server\Module::class,
            'components' => [ 
                'request' => function () { 
                    return \filsh\yii2\oauth2server\Request::createFromGlobals();
                },
                'response' => [
                    'class' => \filsh\yii2\oauth2server\Response::class,
                ],
            ],
    ...

from yii2-oauth2-server.

hiqsol avatar hiqsol commented on July 16, 2024

I've met same problem. It comes from this commit:

yiisoft/yii2@4081a4b

Now yii Module gets components from parents by default.

But actual problem is that this Module shouldn't keep Request and Response as components.
Code should be something like this:

    if ($this->_request === null) {
        $this->_request = Request::createFromGlobals();
    }
    return $this->_request;

from yii2-oauth2-server.

oisoftware avatar oisoftware commented on July 16, 2024

@hiqsol @yogeshs1989 How did you resolve this issue. We are having the same problem

from yii2-oauth2-server.

yogeshs1989 avatar yogeshs1989 commented on July 16, 2024

@oisoftware I have posted the answer how I have resolved this in my original question only. I haven't tried @hiqsol's solution, but it looks promising.

from yii2-oauth2-server.

luciomr avatar luciomr commented on July 16, 2024

@hiqsol 's solution worked fine here. Tested on Yii 2.14.1 and filsh/yii2-oauth2-server 2.0.1

from yii2-oauth2-server.

zdhukui avatar zdhukui commented on July 16, 2024

Whenever I am calling oauth2/token api, I am getting following exception.

Argument 1 passed to OAuth2\\Server::handleTokenRequest() must be an instance of OAuth2\\RequestInterface, instance of yii\\web\\Request given, called in /Applications/XAMPP/xamppfiles/htdocs/api_new/vendor/filsh/yii2-oauth2-server/Server.php on line 39

Well I have resolved this bug by changing the code in vendor/filsh/yii2-oauth2-server/Module.php file

Earlier Code:-

public function getRequest()
{
if(!$this->has('request')) {
$this->set('request', Request::createFromGlobals());
}
return $this->get('request');
}

Changed Code:-

public function getRequest()
{
$this->set('request', \OAuth2\Request::createFromGlobals());
return $this->get('request');
}

It works! Thanks!

from yii2-oauth2-server.

zdhukui avatar zdhukui commented on July 16, 2024

This is how I solved the problem through configuration.
It's a bit rude but requires no chages to this package.

    'modules' => [ 
        'oauth2' => [ 
            'class' => \filsh\yii2\oauth2server\Module::class,
            'components' => [ 
                'request' => function () { 
                    return \filsh\yii2\oauth2server\Request::createFromGlobals();
                },
                'response' => [
                    'class' => \filsh\yii2\oauth2server\Response::class,
                ],
            ],
    ...

HOHO, good method, thanks

           'class' => \filsh\yii2\oauth2server\Module::class,
           'tokenParamName' => 'accessToken',
          'tokenAccessLifetime' => 3600 * 24,
           'storageMap' => [
               'user_credentials' => 'common\models\User',
           ],
           'grantTypes' => [
              'user_credentials' => [
                   'class' => 'OAuth2\GrantType\UserCredentials',
               ],
               'refresh_token' => [
                   'class' => 'OAuth2\GrantType\RefreshToken',
                   'always_issue_new_refresh_token' => true
               ]
           ],
           'components' => [
               'request' => function () {
                  return \filsh\yii2\oauth2server\Request::createFromGlobals();
              },
               'response' => [
                   'class' => \filsh\yii2\oauth2server\Response::class,
               ],
           ],
```        ],

from yii2-oauth2-server.

ar1fbudiman avatar ar1fbudiman commented on July 16, 2024

Whenever I am calling oauth2/token api, I am getting following exception.

Argument 1 passed to OAuth2\\Server::handleTokenRequest() must be an instance of OAuth2\\RequestInterface, instance of yii\\web\\Request given, called in /Applications/XAMPP/xamppfiles/htdocs/api_new/vendor/filsh/yii2-oauth2-server/Server.php on line 39

Well I have resolved this bug by changing the code in vendor/filsh/yii2-oauth2-server/Module.php file

Earlier Code:-

public function getRequest()
{
if(!$this->has('request')) {
$this->set('request', Request::createFromGlobals());
}
return $this->get('request');
}

Changed Code:-

public function getRequest()
{
$this->set('request', \OAuth2\Request::createFromGlobals());
return $this->get('request');
}

worked for me, thank you

from yii2-oauth2-server.

varp avatar varp commented on July 16, 2024

@hiqsol @yogeshs1989 @luciomr @oisoftware @zdhukui Fixed in v2.1.0

from yii2-oauth2-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.