Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nodge/EAuth Google Oauth2 Stopped Working #122

Closed
Juanfcomoraless opened this issue Sep 14, 2018 · 6 comments
Closed

Nodge/EAuth Google Oauth2 Stopped Working #122

Juanfcomoraless opened this issue Sep 14, 2018 · 6 comments

Comments

@Juanfcomoraless
Copy link

What steps will reproduce the problem?

Authentication to Yii2 with Google OAuth2 using nodge/eauth

What's expected?

Successful login

What do you get instead?

EAuthException: Error in retrieving token: "redirect_uri_mismatch"

Additional info

Q A
Yii version 2.0.5
Yii Auth Client version 2.0
Yii HTTP Client version
PHP version 5.4
Operating system Debian 7.2 (AMD64)
  1. We has not updated the code from our websites
  2. We have the same problem in all servers (with Debian 7.2)
  3. We create Google API project, client, etc. was created, under a different Google Developer console account, same result

Thanks.

@demimurych
Copy link

I also had the same problem.

@Rjgoolsby
Copy link

Same here. If anyone figures out a fix please share. I'll be working on this all day today unfortunately

@demimurych
Copy link

demimurych commented Sep 14, 2018

I found where the error is.
Redirect URl and callback URL should be the same.

Dirty fix -
/var/www/heaven/vendor/nodge/yii2-eauth/src/oauth2/Service.php
add "scope" in to filter aparametres (see bold)

It was
foreach (['code', 'state', 'redirect_uri'] as $param) {

has become
foreach (['code', 'state', 'redirect_uri', 'scope'] as $param) {

protected function getCallbackUrl()
	{
           
        
			$url = $_GET['redirect_uri'];
		}
		else {
			$route = Yii::$app->getRequest()->getQueryParams();
			array_unshift($route, '');

			// Can not use these params in OAuth2 callbacks
			foreach (['code', 'state', 'redirect_uri', 'scope'] as $param) {
				if (isset($route[$param])) {
					unset($route[$param]);
				}
			}

			$url = Url::to($route, true);
		}

        
		return $url;
	}

@Juanfcomoraless
Copy link
Author

Thank you so much Master, Its works for me.

@Rjgoolsby
Copy link

You beat me to it :-).

I had narrowed it down to the Http Client request body. I didn't get as far as you. Great job @demimurych.

Do anyone know if this project is still maintained? Are you going to submit a pull request or should I?

@Rjgoolsby
Copy link

ACTUALLY There's already a pull request for this #120. I don't know if this project is maintained anymore. @Nodge are you still the maintainer for this? This is a pretty critical PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants