Jacob
Jacob

Reputation: 449

yii2 GoogleOAuth successfull redirect to 404

I'm using yii2-authclient for user login

 'authClientCollection' => [
      'class' => 'yii\authclient\Collection',
      'clients' => [
          'google' => [
              'class' => 'yii\authclient\clients\GoogleOAuth',
              'clientId' => '*********',
              'clientSecret' => '*********',
              'returnUrl'=>'http://mywebsite/frontend/web/index.php?r=site/auth?authclient=google',

          ],

and in the controller :

'auth' => [
     'class' => 'yii\authclient\AuthAction',
     'successCallback' => [$this, 'successCallback'
],

but after redirect from google to http://mywebsite/frontend/web/index.php?r=site/auth?authclient=google' it shows error Not Found (#404)

Upvotes: 3

Views: 454

Answers (1)

Ravi Thanki
Ravi Thanki

Reputation: 289

I have used following code in SecurityController and its working fine in my case so Can check following code ?

public function actions()
{
    
    return [
        'error' => [
            'class' => 'yii\web\ErrorAction',
        ],
        'auth' => [
            'class' => 'yii\authclient\AuthAction',
            'successCallback' => [$this, 'onAuthSuccess'],
        ],
    ];
}

public function onAuthSuccess($client)
{
     write your success code here.
}

Upvotes: 1

Related Questions