OAuth2 Class Not Found Error PHP

Hi.
I am trying to setup Google OAuth2 Login in a PHP project.
On local docker, it seems to we working well. But, I am not getting any information from the userinfo.email scope, after authorization redirect.
So, I tried deploying it to a test server, just in case it was a localhost issue.
But turns out, even the authorization part is not working on the server.

I get the following error when I open the login SA in browser:

{"code":0,"file":"\/var\/www\/html\/dmxConnectLib\/modules\/oauth.php","line":22,"message":"Class 'lib\\oauth\\Oauth2' not found","trace":"#0 \/var\/www\/html\/dmxConnectLib\/lib\/App.php(195): modules\\oauth->authorize(Object(stdClass), 'GoogleLogin', Array)\n#1 \/var\/www\/html\/dmxConnectLib\/lib\/App.php(159): lib\\App->execSteps(Object(stdClass))\n#2 \/var\/www\/html\/dmxConnectLib\/lib\/App.php(127): lib\\App->execSteps(Array)\n#3 \/var\/www\/html\/dmxConnectLib\/lib\/App.php(116): lib\\App->exec(Object(stdClass), false)\n#4 \/var\/www\/html\/dmxConnectLib\/lib\/App.php(94): lib\\App->exec(Object(stdClass))\n#5 \/var\/www\/html\/dmxConnect\/api\/OAuthLogin.php(8): lib\\App->define(Object(stdClass))\n#6 {main}"}

I saw a very old post saying that there was some file naming issue. But even after deleting the dmxConnectLib folder & recreating, the error still remains. Please help.

@patrick Any ideas?

That error comes when the file doesn’t exist or the case is incorrect. Check if lib/oauth/Oauth2.php exists and the case matches exactly.

Interesting. I see the file name is oauth2.php… even though the file name in my folder is Oauth2.php.
Looks like a Git issue.

Looks like it was the same very old issue, just residing in Git.
Old file must have been oauth2.php, and in some release, when it was fixed, Git did not pick it up.
I have seen this before as well. Case changes in filename don’t show up in Git in Windows.

For this, I changed the file to O_auth2.php, committed, and then changed it back to Oauth2.php and committed. That worked. :slight_smile:

Is this CASE issue excusive to Windows or also happens in Mac?
In Linux i’m sure its not an issue.

The problem is that Windows is not case-sensitive and sees Oauth2.php and oauth2.php both as the same file, so that’s probably why git on windows didn’t see the difference. It depends on the filesystem that is used if it is case-sensitive or not, on Mac the default it is not case-sensitive (https://support.apple.com/guide/disk-utility/file-system-formats-dsku19ed921c/mac), but you can make it case-sensitive and on Linux it is in most cases case-sensitive but doesn’t have to.

1 Like